Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F1494778
HandleROSAOptions.cmake
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Size
3 KB
Referenced Files
None
Subscribers
None
HandleROSAOptions.cmake
View Options
# This CMake module is responsible for interpreting the user defined ROSA_
# options and executing the appropriate CMake commands to realize the users'
# selections.
include
(
CheckCCompilerFlag
)
include
(
CheckCXXCompilerFlag
)
if
(
CMAKE_COMPILER_IS_GNUCXX
)
set
(
ROSA_COMPILER_IS_GCC_COMPATIBLE
ON
)
elseif
(
"${CMAKE_CXX_COMPILER_ID}"
MATCHES
"Clang"
)
set
(
ROSA_COMPILER_IS_GCC_COMPATIBLE
ON
)
elseif
(
MSVC
)
set
(
ROSA_COMPILER_IS_GCC_COMPATIBLE
OFF
)
endif
()
function
(
append
value
)
foreach
(
variable
${
ARGN
}
)
set
(
${
variable
}
"${${variable}} ${value}"
PARENT_SCOPE
)
endforeach
(
variable
)
endfunction
()
function
(
append_if
condition
value
)
if
(
${
condition
}
)
foreach
(
variable
${
ARGN
}
)
set
(
${
variable
}
"${${variable}} ${value}"
PARENT_SCOPE
)
endforeach
(
variable
)
endif
()
endfunction
()
# NDEBUG on non-Debug builds
append
(
"-DNDEBUG"
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_C_FLAGS_MINSIZEREL
)
# Assertions are always enabled on Debug builds, this is interesting for
# non-Debug builds.
if
(
NOT
"${uppercase_CMAKE_BUILD_TYPE}"
STREQUAL
"DEBUG"
AND
${
ROSA_ENABLE_ASSERTIONS
}
)
# MSVC doesn't like _DEBUG on release builds. See PR 4379.
if
(
NOT
MSVC
)
add_definitions
(
-D_DEBUG
)
set
(
ENABLE_ASSERTIONS
"1"
)
else
()
set
(
ENABLE_ASSERTIONS
"0"
)
endif
()
# On non-Debug builds we NDEBUG, but in this case we need to undefine it:
add_definitions
(
-UNDEBUG
)
# Also remove /D NDEBUG to avoid MSVC warnings about conflicting defines.
foreach
(
flags_var_to_scrub
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_C_FLAGS_MINSIZEREL
)
string
(
REGEX
REPLACE
"(^| )[/-]D *NDEBUG($| )"
" "
"${flags_var_to_scrub}"
"${${flags_var_to_scrub}}"
)
endforeach
()
endif
()
set
(
ROSA_ENABLE_ASSERTIONS_INT
-1
)
if
(
"${uppercase_CMAKE_BUILD_TYPE}"
STREQUAL
"DEBUG"
OR
${
ROSA_ENABLE_ASSERTIONS
}
)
set
(
ROSA_ENABLE_ASSERTIONS_INT
1
)
endif
()
if
(
ROSA_COMPILER_IS_GCC_COMPATIBLE
)
append
(
"-Wall -Wextra -Wdocumentation -Werror"
CMAKE_C_FLAGS
CMAKE_CXX_FLAGS
)
append_if
(
ROSA_ENABLE_PEDANTIC
"-pedantic -Wno-long-long"
CMAKE_C_FLAGS
CMAKE_CXX_FLAGS
)
append
(
"-fno-rtti -fno-exceptions"
CMAKE_CXX_FLAGS
)
check_cxx_compiler_flag
(
"-std=c++14"
CXX_SUPPORTS_CXX14
)
if
(
CXX_SUPPORTS_CXX14
)
append
(
"-std=c++14"
CMAKE_CXX_FLAGS
)
else
()
message
(
FATAL_ERROR
"RoSA requires C++14 support but the '-std=c++14' flag isn't supported."
)
endif
()
check_c_compiler_flag
(
"-std=c11"
C_SUPPORTS_C11
)
if
(
C_SUPPORTS_C11
)
append
(
"-std=c11"
CMAKE_C_FLAGS
)
else
()
message
(
FATAL_ERROR
"RoSA requires C11 support but the '-std=c11' flag isn't supported."
)
endif
()
else
(
ROSA_COMPILER_IS_GCC_COMPATIBLE
)
# FIXME: set the same things as for GCC-compatible compilers
endif
(
ROSA_COMPILER_IS_GCC_COMPATIBLE
)
if
(
ROSA_ENABLE_CLANG_TIDY
)
# Set clang-tidy arguments, use the same for both C and CXX.
set
(
CMAKE_C_CLANG_TIDY
"${CLANGTIDY_EXECUTABLE};-header-filter=.*"
)
set
(
CMAKE_CXX_CLANG_TIDY
${
CMAKE_C_CLANG_TIDY
}
)
# Apply suggested fixes if requested.
append_if
(
ROSA_CLANG_TIDY_FIX
",-fix"
CMAKE_C_CLANG_TIDY
CMAKE_CXX_CLANG_TIDY
)
endif
(
ROSA_ENABLE_CLANG_TIDY
)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Mar 1, 6:55 PM (2 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
288121
Default Alt Text
HandleROSAOptions.cmake (3 KB)
Attached To
Mode
R20 SoC_Rosa_repo
Attached
Detach File
Event Timeline
Log In to Comment