diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2018-09-05 15:14:14 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2018-09-05 15:28:29 +0200 |
commit | 91800eb2436269993493b606b905cf0572e945e2 (patch) | |
tree | 68c07713e840767d8667b7a17bcc4686c716b675 /cmake | |
parent | 2923ad59f9d2598418e7ba6369cb9fafc21cea09 (diff) | |
download | libssh-91800eb2436269993493b606b905cf0572e945e2.tar.gz libssh-91800eb2436269993493b606b905cf0572e945e2.tar.xz libssh-91800eb2436269993493b606b905cf0572e945e2.zip |
cmake: Move CompilerFlags to own file
They need to be included before the project() call.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/Modules/AddCMockaTest.cmake | 26 | ||||
-rw-r--r-- | cmake/Modules/DefineCompilerFlags.cmake | 25 |
2 files changed, 25 insertions, 26 deletions
diff --git a/cmake/Modules/AddCMockaTest.cmake b/cmake/Modules/AddCMockaTest.cmake index 02b36cff..db565fd9 100644 --- a/cmake/Modules/AddCMockaTest.cmake +++ b/cmake/Modules/AddCMockaTest.cmake @@ -9,32 +9,6 @@ enable_testing() include(CTest) -if((CMAKE_C_COMPILER_ID MATCHES "(GNU|Clang)") AND NOT MINGW) - # Activate with: -DCMAKE_BUILD_TYPE=Profiling - set(CMAKE_C_FLAGS_PROFILING "-g -O0 -fprofile-arcs -ftest-coverage" - CACHE STRING "Flags used by the C compiler during PROFILING builds.") - set(CMAKE_CXX_FLAGS_PROFILING "-g -O0 -fprofile-arcs -ftest-coverage" - CACHE STRING "Flags used by the CXX compiler during PROFILING builds.") - set(CMAKE_SHARED_LINKER_FLAGS_PROFILING "-fprofile-arcs -ftest-coverage" - CACHE STRING "Flags used by the linker during the creation of shared libraries during PROFILING builds.") - set(CMAKE_MODULE_LINKER_FLAGS_PROFILING "-fprofile-arcs -ftest-coverage" - CACHE STRING "Flags used by the linker during the creation of shared libraries during PROFILING builds.") - set(CMAKE_EXEC_LINKER_FLAGS_PROFILING "-fprofile-arcs -ftest-coverage" - CACHE STRING "Flags used by the linker during PROFILING builds.") - - # Activate with: -DCMAKE_BUILD_TYPE=AddressSanitizer - set(CMAKE_C_FLAGS_ADDRESSSANITIZER "-g -O1 -fsanitize=address -fno-omit-frame-pointer" - CACHE STRING "Flags used by the C compiler during ADDRESSSANITIZER builds.") - set(CMAKE_CXX_FLAGS_ADDRESSSANITIZER "-g -O1 -fsanitize=address -fno-omit-frame-pointer" - CACHE STRING "Flags used by the CXX compiler during ADDRESSSANITIZER builds.") - set(CMAKE_SHARED_LINKER_FLAGS_ADDRESSSANITIZER "-fsanitize=address" - CACHE STRING "Flags used by the linker during the creation of shared libraries during ADDRESSSANITIZER builds.") - set(CMAKE_MODULE_LINKER_FLAGS_ADDRESSSANITIZER "-fsanitize=address" - CACHE STRING "Flags used by the linker during the creation of shared libraries during ADDRESSSANITIZER builds.") - set(CMAKE_EXEC_LINKER_FLAGS_ADDRESSSANITIZER "-fsanitize=address" - CACHE STRING "Flags used by the linker during ADDRESSSANITIZER builds.") -endif() - if (CMAKE_CROSSCOMPILING) if (WIN32) find_program(WINE_EXECUTABLE diff --git a/cmake/Modules/DefineCompilerFlags.cmake b/cmake/Modules/DefineCompilerFlags.cmake new file mode 100644 index 00000000..75b40136 --- /dev/null +++ b/cmake/Modules/DefineCompilerFlags.cmake @@ -0,0 +1,25 @@ +if (UNIX AND NOT WIN32) + # Activate with: -DCMAKE_BUILD_TYPE=Profiling + set(CMAKE_C_FLAGS_PROFILING "-g -O0 -fprofile-arcs -ftest-coverage" + CACHE STRING "Flags used by the C compiler during PROFILING builds.") + set(CMAKE_CXX_FLAGS_PROFILING "-g -O0 -fprofile-arcs -ftest-coverage" + CACHE STRING "Flags used by the CXX compiler during PROFILING builds.") + set(CMAKE_SHARED_LINKER_FLAGS_PROFILING "-fprofile-arcs -ftest-coverage" + CACHE STRING "Flags used by the linker during the creation of shared libraries during PROFILING builds.") + set(CMAKE_MODULE_LINKER_FLAGS_PROFILING "-fprofile-arcs -ftest-coverage" + CACHE STRING "Flags used by the linker during the creation of shared libraries during PROFILING builds.") + set(CMAKE_EXEC_LINKER_FLAGS_PROFILING "-fprofile-arcs -ftest-coverage" + CACHE STRING "Flags used by the linker during PROFILING builds.") + + # Activate with: -DCMAKE_BUILD_TYPE=AddressSanitizer + set(CMAKE_C_FLAGS_ADDRESSSANITIZER "-g -O1 -fsanitize=address -fno-omit-frame-pointer" + CACHE STRING "Flags used by the C compiler during ADDRESSSANITIZER builds.") + set(CMAKE_CXX_FLAGS_ADDRESSSANITIZER "-g -O1 -fsanitize=address -fno-omit-frame-pointer" + CACHE STRING "Flags used by the CXX compiler during ADDRESSSANITIZER builds.") + set(CMAKE_SHARED_LINKER_FLAGS_ADDRESSSANITIZER "-fsanitize=address" + CACHE STRING "Flags used by the linker during the creation of shared libraries during ADDRESSSANITIZER builds.") + set(CMAKE_MODULE_LINKER_FLAGS_ADDRESSSANITIZER "-fsanitize=address" + CACHE STRING "Flags used by the linker during the creation of shared libraries during ADDRESSSANITIZER builds.") + set(CMAKE_EXEC_LINKER_FLAGS_ADDRESSSANITIZER "-fsanitize=address" + CACHE STRING "Flags used by the linker during ADDRESSSANITIZER builds.") +endif() |