aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2020-01-31 13:19:41 +0100
committerAndreas Schneider <asn@samba.org>2020-01-31 13:27:34 +0100
commitad58c0b68c9f174ed8411e64ea4f1ee0caa6c8ef (patch)
tree3d4c9652fcc72bbf1acb3bc1ebacd4587af8319a
parented773b8b1e883696531f4a69d74283e2ce473257 (diff)
downloadpam_wrapper-ad58c0b68c9f174ed8411e64ea4f1ee0caa6c8ef.tar.gz
pam_wrapper-ad58c0b68c9f174ed8411e64ea4f1ee0caa6c8ef.tar.xz
pam_wrapper-ad58c0b68c9f174ed8411e64ea4f1ee0caa6c8ef.zip
cmake: Move compiler flags to new file
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
-rw-r--r--CMakeLists.txt15
-rw-r--r--cmake/Modules/AddCMockaTest.cmake7
-rw-r--r--cmake/Modules/DefineCompilerFlags.cmake13
3 files changed, 22 insertions, 13 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 608f94f..a69a908 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,6 +2,15 @@
cmake_minimum_required(VERSION 3.5.0)
cmake_policy(SET CMP0048 NEW)
+# Specify search path for CMake modules to be loaded by include()
+# and find_package()
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
+
+# Add defaults for cmake
+# Those need to be set before the project() call.
+include(DefineCMakeDefaults)
+include(DefineCompilerFlags)
+
project(pam_wrapper VERSION 1.0.7 LANGUAGES C)
# global needed variables
@@ -20,13 +29,7 @@ set(LIBRARY_SOVERSION "0")
set(PAMTEST_LIBRARY_VERSION "0.0.4")
set(PAMTEST_LIBRARY_SOVERSION "0")
-# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
-set(CMAKE_MODULE_PATH
- ${CMAKE_SOURCE_DIR}/cmake/Modules
-)
-
# add definitions
-include(DefineCMakeDefaults)
include(DefinePlatformDefaults)
include(DefineInstallationPaths)
include(DefineOptions.cmake)
diff --git a/cmake/Modules/AddCMockaTest.cmake b/cmake/Modules/AddCMockaTest.cmake
index b2d1ca8..6a34e76 100644
--- a/cmake/Modules/AddCMockaTest.cmake
+++ b/cmake/Modules/AddCMockaTest.cmake
@@ -9,13 +9,6 @@
enable_testing()
include(CTest)
-if(CMAKE_COMPILER_IS_GNUCC AND NOT MINGW)
- set(CMAKE_C_FLAGS_PROFILING "-g -O0 -Wall -W -Wshadow -Wunused-variable -Wunused-parameter -Wunused-function -Wunused -Wno-system-headers -Wwrite-strings -fprofile-arcs -ftest-coverage" CACHE STRING "Profiling Compiler Flags")
- set(CMAKE_SHARED_LINKER_FLAGS_PROFILING " -fprofile-arcs -ftest-coverage" CACHE STRING "Profiling Linker Flags")
- set(CMAKE_MODULE_LINKER_FLAGS_PROFILING " -fprofile-arcs -ftest-coverage" CACHE STRING "Profiling Linker Flags")
- set(CMAKE_EXEC_LINKER_FLAGS_PROFILING " -fprofile-arcs -ftest-coverage" CACHE STRING "Profiling Linker Flags")
-endif(CMAKE_COMPILER_IS_GNUCC AND NOT MINGW)
-
function (ADD_CMOCKA_TEST _testName _testSource)
add_executable(${_testName} ${_testSource})
target_link_libraries(${_testName} ${ARGN})
diff --git a/cmake/Modules/DefineCompilerFlags.cmake b/cmake/Modules/DefineCompilerFlags.cmake
new file mode 100644
index 0000000..4edb6d9
--- /dev/null
+++ b/cmake/Modules/DefineCompilerFlags.cmake
@@ -0,0 +1,13 @@
+if (UNIX AND NOT WIN32)
+ # Activate with: -DCMAKE_BUILD_TYPE=Profiling
+ set(CMAKE_C_FLAGS_PROFILING "-O0 -g -fprofile-arcs -ftest-coverage"
+ CACHE STRING "Flags used by the C compiler during PROFILING builds.")
+ set(CMAKE_CXX_FLAGS_PROFILING "-O0 -g -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.")
+endif()