[SCM] pam wrapper repository - branch master updated

Andreas Schneider asn at samba.org
Tue Mar 3 16:07:43 UTC 2020


The branch, master has been updated
       via  cb99388 gitlab-ci: Setup CI for pam_wrapper
       via  3157c03 cmake: Do not run python tests with AddressSanitizer
       via  c6e0341 cmake: Write new cmake config files
       via  c79a3f8 cmake: Use GNUInstallDirs
       via  df8ae93 cmake: Use target_include_directories()
       via  81078a8 cmake: Support running the tests with AddressSanitizer
       via  43b185e cmake: Add AddressSanitizer and UndefinedSanitizer
       via  a4880ff cmake: Update add_cmocka_test()
       via  678fa2c cmake: Look for cmocka 1.1.0 at least
       via  ad58c0b cmake: Move compiler flags to new file
       via  ed773b8 cmake: Improve checks for compiler flags
       via  0683ae5 cmake: Update cmake defaults
       via  68aa7b7 cmake: Require at least cmake 3.5.0
       via  8906d52 README: Rename to a markdown file
       via  fdce4f6 doc: Document PAM_WRAPPER_DISABLE_DEEPBIND
       via  047e9fb pwrap: Fix pso_copy to work with libpam.so.0.84.2
       via  50036d0 pwrap: Use a define in pso_copy()
       via  17ca36e pwrap: Improve logging
       via  247cf61 cmake: Add checks for getprogname() and getexecname()
       via  831aeb5 pwrap: Add support for running with Sanitizers
       via  ffd79f8 cpack: Do not package pyc files
      from  61283c9 Bump version to 1.0.7

https://git.samba.org/?p=pam_wrapper.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit cb9938838c4dfd5720b4e778fc39aeee7bf49f09
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Jan 31 14:01:27 2020 +0100

    gitlab-ci: Setup CI for pam_wrapper
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 3157c038957c4a0dd29869aa5d5cccdde00efa19
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Jan 31 14:57:44 2020 +0100

    cmake: Do not run python tests with AddressSanitizer
    
    It will complain about python malloc and fail.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit c6e0341042ead637ccf6a83f13a4a993b18b17ce
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Jan 31 13:59:52 2020 +0100

    cmake: Write new cmake config files
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit c79a3f83f121ff92925d72bd751dc907be12fd8a
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Jan 31 13:47:37 2020 +0100

    cmake: Use GNUInstallDirs
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit df8ae930178aade3f8d3160735d2157aa5f2cb15
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Jan 31 13:41:35 2020 +0100

    cmake: Use target_include_directories()
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 81078a8d6d40189390218b9ae2b42cc258d745aa
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Jan 31 13:32:46 2020 +0100

    cmake: Support running the tests with AddressSanitizer
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 43b185e1696562ba17ea05e3574f030f911aa8cb
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Jan 31 13:21:06 2020 +0100

    cmake: Add AddressSanitizer and UndefinedSanitizer
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit a4880ffaa12b61be8177c099e50e704a29e72f3b
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Jan 31 13:25:59 2020 +0100

    cmake: Update add_cmocka_test()
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 678fa2c414e10c7e3a7ee840536044af036342de
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Jan 31 13:22:50 2020 +0100

    cmake: Look for cmocka 1.1.0 at least
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit ad58c0b68c9f174ed8411e64ea4f1ee0caa6c8ef
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Jan 31 13:19:41 2020 +0100

    cmake: Move compiler flags to new file
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit ed773b8b1e883696531f4a69d74283e2ce473257
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Jan 31 13:16:45 2020 +0100

    cmake: Improve checks for compiler flags
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 0683ae515f12539e2de71e3b770df3a3d637e089
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Jan 31 13:06:13 2020 +0100

    cmake: Update cmake defaults
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 68aa7b7826e84c9fd15bdd0618dd4a2b30896c0d
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Jan 31 12:59:31 2020 +0100

    cmake: Require at least cmake 3.5.0
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 8906d52333bcdf370ca436b8ee6dd64b58291354
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Jan 31 13:03:33 2020 +0100

    README: Rename to a markdown file
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit fdce4f687fe76766a3f336a22a659efcfbef421f
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Jan 31 12:48:58 2020 +0100

    doc: Document PAM_WRAPPER_DISABLE_DEEPBIND
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 047e9fb616d21e202add9f16347cea2084444104
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Nov 15 09:58:27 2019 +0100

    pwrap: Fix pso_copy to work with libpam.so.0.84.2
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 50036d052a5746c91d94ceb7eb68a1aa9d8554fb
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Nov 15 09:45:22 2019 +0100

    pwrap: Use a define in pso_copy()
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 17ca36ee3899d0ee4936c1be235de06cab148ae5
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Nov 15 09:40:04 2019 +0100

    pwrap: Improve logging
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 247cf61399585caebcd2b8af7b91a08547e148b5
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Nov 15 09:39:21 2019 +0100

    cmake: Add checks for getprogname() and getexecname()
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 831aeb5271d6f16edbe6ed354723af247b9227b9
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Nov 15 09:34:03 2019 +0100

    pwrap: Add support for running with Sanitizers
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit ffd79f882f8eff32d36798edd15f179402301e48
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Feb 28 12:58:28 2019 +0100

    cpack: Do not package pyc files
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 .gitlab-ci.yml                                  | 210 ++++++++++++++++++++++++
 CMakeLists.txt                                  |  72 ++++----
 CPackConfig.cmake                               |  13 +-
 CompilerChecks.cmake                            | 114 +++++++++++++
 ConfigureChecks.cmake                           |  14 +-
 DefineOptions.cmake                             |   1 +
 README => README.md                             |   6 +-
 cmake/Modules/AddCCompilerFlag.cmake            |  21 +++
 cmake/Modules/AddCMockaTest.cmake               | 148 +++++++++++++++--
 cmake/Modules/CheckCCompilerFlagSSP.cmake       |  36 +++-
 cmake/Modules/DefineCMakeDefaults.cmake         |  19 +--
 cmake/Modules/DefineCompilerFlags.cmake         | 113 ++++---------
 cmake/Modules/DefineInstallationPaths.cmake     | 109 ------------
 cmake/Modules/MacroEnsureOutOfSourceBuild.cmake |  17 --
 config.h.cmake                                  |  11 +-
 doc/pam_wrapper.1                               |  19 ++-
 doc/pam_wrapper.1.txt                           |   8 +-
 include/CMakeLists.txt                          |  11 +-
 libpamtest-config.cmake.in                      |  11 --
 pam_wrapper-config.cmake.in                     |   4 +-
 pam_wrapper.pc.cmake                            |   8 +-
 src/CMakeLists.txt                              |  50 +++---
 src/modules/CMakeLists.txt                      |  11 +-
 src/pam_wrapper.c                               | 102 +++++++++---
 src/python/python2/CMakeLists.txt               |   4 +-
 src/python/python3/CMakeLists.txt               |   4 +-
 tests/CMakeLists.txt                            | 107 ++++++++----
 27 files changed, 822 insertions(+), 421 deletions(-)
 create mode 100644 .gitlab-ci.yml
 create mode 100644 CompilerChecks.cmake
 rename README => README.md (75%)
 create mode 100644 cmake/Modules/AddCCompilerFlag.cmake
 delete mode 100644 cmake/Modules/DefineInstallationPaths.cmake
 delete mode 100644 cmake/Modules/MacroEnsureOutOfSourceBuild.cmake
 delete mode 100644 libpamtest-config.cmake.in


Changeset truncated at 500 lines:

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 0000000..440521d
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,210 @@
+variables:
+  GIT_DEPTH: 3
+  BUILD_IMAGES_PROJECT: cmocka/gitlab-build-images
+  FEDORA_BUILD: buildenv-fedora
+  CENTOS7_BUILD: buildenv-centos7
+  TUMBLEWEED_BUILD: buildenv-tumbleweed
+
+centos7/x86_64:
+  image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$CENTOS7_BUILD
+  script:
+  - mkdir -p obj && cd obj && cmake3
+    -DCMAKE_BUILD_TYPE=RelWithDebInfo
+    -DPICKY_DEVELOPER=ON
+    -DUNIT_TESTING=ON .. &&
+    make -j$(nproc) && ctest --output-on-failure
+  tags:
+  - shared
+  except:
+  - tags
+  artifacts:
+    expire_in: 1 week
+    when: on_failure
+    paths:
+      - obj/
+
+fedora/x86_64:
+  image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD
+  script:
+  - mkdir -p obj && cd obj && cmake
+    -DCMAKE_INSTALL_PREFIX=/tmp/local
+    -DCMAKE_BUILD_TYPE=RelWithDebInfo
+    -DPICKY_DEVELOPER=ON
+    -DUNIT_TESTING=ON .. &&
+    make -j$(nproc) && ctest --output-on-failure && make install
+  tags:
+  - shared
+  except:
+  - tags
+  artifacts:
+    expire_in: 1 week
+    when: on_failure
+    paths:
+      - obj/
+
+fedora/address-sanitizer:
+  image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD
+  script:
+  - mkdir -p obj && cd obj && cmake
+    -DCMAKE_BUILD_TYPE=AddressSanitizer
+    -DPICKY_DEVELOPER=ON
+    -DUNIT_TESTING=ON .. &&
+    make -j$(nproc) && ctest --output-on-failure
+  tags:
+  - shared
+  except:
+  - tags
+  artifacts:
+    expire_in: 1 week
+    when: on_failure
+    paths:
+      - obj/
+
+fedora/undefined-sanitizer:
+  image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD
+  script:
+  - mkdir -p obj && cd obj && cmake
+    -DCMAKE_BUILD_TYPE=UndefinedSanitizer
+    -DPICKY_DEVELOPER=ON
+    -DUNIT_TESTING=ON ..
+    && make -j$(nproc) && ctest --output-on-failure
+  tags:
+  - shared
+  except:
+  - tags
+  artifacts:
+    expire_in: 1 week
+    when: on_failure
+    paths:
+      - obj/
+
+fedora/csbuild:
+  variables:
+    GIT_DEPTH: 20
+  image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD
+  script:
+  - |
+    if [[ -z "$CI_COMMIT_BEFORE_SHA" ]]; then
+        export CI_COMMIT_BEFORE_SHA=$(git rev-parse "${CI_COMMIT_SHA}~15")
+    fi
+
+    # Check if the commit exists in this branch
+    # This is not the case for a force push
+    git branch --contains $CI_COMMIT_BEFORE_SHA 2>/dev/null || export CI_COMMIT_BEFORE_SHA=$(git rev-parse "${CI_COMMIT_SHA}~15")
+
+    export CI_COMMIT_RANGE="$CI_COMMIT_BEFORE_SHA..$CI_COMMIT_SHA"
+
+  - csbuild
+    --build-dir=obj-csbuild
+    --prep-cmd="cmake -DCMAKE_BUILD_TYPE=Debug -DPICKY_DEVELOPER=ON -DUNIT_TESTING=ON @SRCDIR@"
+    --build-cmd "make clean && make -j$(nproc)"
+    --git-commit-range $CI_COMMIT_RANGE
+    --color
+    --print-current --print-fixed
+  tags:
+  - shared
+  except:
+  - tags
+  artifacts:
+    expire_in: 1 week
+    when: on_failure
+    paths:
+      - obj-csbuild/
+
+freebsd/x86_64:
+  image:
+  script:
+  - mkdir -p obj && cd obj && cmake
+    -DCMAKE_BUILD_TYPE=RelWithDebInfo
+    -DPICKY_DEVELOPER=ON
+    -DUNIT_TESTING=ON .. &&
+    make && ctest --output-on-failure
+  tags:
+  - freebsd
+  except:
+  - tags
+  only:
+  - branches at cwrap/pam_wrapper
+  - branches at cryptomilk/pam_wrapper
+  artifacts:
+    expire_in: 1 week
+    when: on_failure
+    paths:
+      - obj/
+
+tumbleweed/x86_64/gcc:
+  image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$TUMBLEWEED_BUILD
+  script:
+  - mkdir -p obj && cd obj && cmake
+    -DCMAKE_BUILD_TYPE=RelWithDebInfo
+    -DPICKY_DEVELOPER=ON
+    -DUNIT_TESTING=ON .. &&
+    make -j$(nproc) && ctest --output-on-failure
+  tags:
+  - shared
+  except:
+  - tags
+  artifacts:
+    expire_in: 1 week
+    when: on_failure
+    paths:
+      - obj/
+
+tumbleweed/x86_64/gcc7:
+  image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$TUMBLEWEED_BUILD
+  script:
+  - mkdir -p obj && cd obj && cmake
+    -DCMAKE_C_COMPILER=gcc-7 -DCMAKE_CXX_COMPILER=g++-7
+    -DCMAKE_BUILD_TYPE=RelWithDebInfo
+    -DPICKY_DEVELOPER=ON
+    -DUNIT_TESTING=ON .. &&
+    make -j$(nproc) && ctest --output-on-failure
+  tags:
+  - shared
+  except:
+  - tags
+  artifacts:
+    expire_in: 1 week
+    when: on_failure
+    paths:
+      - obj/
+
+tumbleweed/x86_64/clang:
+  image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$TUMBLEWEED_BUILD
+  script:
+  - mkdir -p obj && cd obj && cmake
+    -DCMAKE_BUILD_TYPE=RelWithDebInfo
+    -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
+    -DPICKY_DEVELOPER=ON
+    -DUNIT_TESTING=ON .. &&
+    make -j$(nproc) && ctest --output-on-failure
+  tags:
+  - shared
+  except:
+  - tags
+  artifacts:
+    expire_in: 1 week
+    when: on_failure
+    paths:
+      - obj/
+
+tumbleweed/static-analysis:
+  image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$TUMBLEWEED_BUILD
+  script:
+  - export CCC_CC=clang
+  - export CCC_CXX=clang++
+  - mkdir -p obj && cd obj && scan-build cmake
+    -DCMAKE_BUILD_TYPE=Debug
+    -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
+    -DPICKY_DEVELOPER=ON
+    -DUNIT_TESTING=ON .. &&
+    scan-build --status-bugs -o scan make -j$(nproc)
+  tags:
+  - shared
+  except:
+  - tags
+  artifacts:
+    expire_in: 1 week
+    when: on_failure
+    paths:
+      - obj/scan
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3b0f148..7d646da 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,16 +1,20 @@
-project(pam_wrapper C)
-
 # Required cmake version
-cmake_minimum_required(VERSION 2.8.0)
+cmake_minimum_required(VERSION 3.5.0)
+cmake_policy(SET CMP0048 NEW)
 
-# global needed variables
-set(APPLICATION_NAME ${PROJECT_NAME})
+# 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)
 
-set(APPLICATION_VERSION_MAJOR "1")
-set(APPLICATION_VERSION_MINOR "0")
-set(APPLICATION_VERSION_PATCH "7")
+project(pam_wrapper VERSION 1.0.7 LANGUAGES C)
 
-set(APPLICATION_VERSION "${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH}")
+# global needed variables
+set(APPLICATION_NAME ${PROJECT_NAME})
 
 # SOVERSION scheme: CURRENT.AGE.REVISION
 #   If there was an incompatible interface change:
@@ -25,22 +29,12 @@ 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(DefineCompilerFlags)
-include(DefineInstallationPaths)
+include(GNUInstallDirs)
 include(DefineOptions.cmake)
 include(CPackConfig.cmake)
-
-# disallow in-source build
-include(MacroEnsureOutOfSourceBuild)
-macro_ensure_out_of_source_build("${PROJECT_NAME} requires an out of source build. Please create a separate build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there.")
+include(CompilerChecks.cmake)
 
 # Find out if we have threading available
 set(CMAKE_THREAD_PREFER_PTHREADS ON)
@@ -51,11 +45,11 @@ include(ConfigureChecks.cmake)
 configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
 
 # check subdirectories
-add_subdirectory(src)
 add_subdirectory(include)
+add_subdirectory(src)
 
 if (UNIT_TESTING)
-    find_package(CMocka REQUIRED)
+    find_package(CMocka 1.1.0 REQUIRED)
     include(AddCMockaTest)
     add_subdirectory(tests)
 endif (UNIT_TESTING)
@@ -68,7 +62,7 @@ install(
   FILES
     ${CMAKE_CURRENT_BINARY_DIR}/pam_wrapper.pc
   DESTINATION
-    ${LIB_INSTALL_DIR}/pkgconfig
+    ${CMAKE_INSTALL_LIBDIR}/pkgconfig
   COMPONENT
     pkgconfig
 )
@@ -78,37 +72,33 @@ install(
   FILES
     ${CMAKE_CURRENT_BINARY_DIR}/libpamtest.pc
   DESTINATION
-    ${LIB_INSTALL_DIR}/pkgconfig
+    ${CMAKE_INSTALL_LIBDIR}/pkgconfig
   COMPONENT
     pkgconfig
 )
 
 # cmake config files
-configure_file(pam_wrapper-config-version.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/pam_wrapper-config-version.cmake @ONLY)
+include(CMakePackageConfigHelpers)
+
+write_basic_package_version_file(pam_wrapper-config-version.cmake
+                                 COMPATIBILITY
+                                     AnyNewerVersion)
 configure_file(pam_wrapper-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/pam_wrapper-config.cmake @ONLY)
 install(
     FILES
         ${CMAKE_CURRENT_BINARY_DIR}/pam_wrapper-config-version.cmake
         ${CMAKE_CURRENT_BINARY_DIR}/pam_wrapper-config.cmake
     DESTINATION
-        ${CMAKE_INSTALL_DIR}/pam_wrapper
+        ${CMAKE_INSTALL_LIBDIR}/cmake/pam_wrapper
     COMPONENT
         devel
 )
 
-set(LIBPAMTEST_LIBRARY_NAME ${CMAKE_SHARED_LIBRARY_PREFIX}pamtest${CMAKE_SHARED_LIBRARY_SUFFIX})
-
-configure_file(libpamtest-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/libpamtest-config.cmake @ONLY)
-configure_file(libpamtest-config-version.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/libpamtest-config-version.cmake @ONLY)
-
-install(
-    FILES
-        ${CMAKE_CURRENT_BINARY_DIR}/libpamtest-config.cmake
-        ${CMAKE_CURRENT_BINARY_DIR}/libpamtest-config-version.cmake
-    DESTINATION
-        ${CMAKE_INSTALL_DIR}/libpamtest
-    COMPONENT
-        devel
-)
+write_basic_package_version_file(pamtest-config-version.cmake
+                                 COMPATIBILITY
+                                     AnyNewerVersion)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pamtest-config-version.cmake
+        DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pamtest
+        COMPONENT devel)
 
 add_subdirectory(doc)
diff --git a/CPackConfig.cmake b/CPackConfig.cmake
index 88caa30..6081d8f 100644
--- a/CPackConfig.cmake
+++ b/CPackConfig.cmake
@@ -2,28 +2,25 @@
 # http://www.cmake.org/Wiki/CMake:CPackConfiguration
 
 ### general settings
-set(CPACK_PACKAGE_NAME ${APPLICATION_NAME})
+set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The pam_wrapper")
-set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README")
+set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.md")
 set(CPACK_PACKAGE_VENDOR "Samba Team")
 set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME})
 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
 
 
 ### versions
-set(CPACK_PACKAGE_VERSION_MAJOR "${APPLICATION_VERSION_MAJOR}")
-set(CPACK_PACKAGE_VERSION_MINOR "${APPLICATION_VERSION_MINOR}")
-set(CPACK_PACKAGE_VERSION_PATCH "${APPLICATION_VERSION_PATCH}")
-set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
+set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
 
 
 ### source generator
 set(CPACK_SOURCE_GENERATOR "TGZ")
-set(CPACK_SOURCE_IGNORE_FILES "~$;[.]swp$;/[.]svn/;/[.]git/;.gitignore;/build*;/obj*;tags;cscope.*")
+set(CPACK_SOURCE_IGNORE_FILES "~$;[.]swp$;/[.]svn/;/[.]git/;.gitignore;/build*;/obj*;tags;cscope.*;*.pyc")
 set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
 
 set(CPACK_PACKAGE_INSTALL_DIRECTORY "pam_wrapper")
 
-set(CPACK_PACKAGE_FILE_NAME ${APPLICATION_NAME}-${CPACK_PACKAGE_VERSION})
+set(CPACK_PACKAGE_FILE_NAME ${PROJECT_NAME}-${CPACK_PACKAGE_VERSION})
 
 include(CPack)
diff --git a/CompilerChecks.cmake b/CompilerChecks.cmake
new file mode 100644
index 0000000..4fa1a83
--- /dev/null
+++ b/CompilerChecks.cmake
@@ -0,0 +1,114 @@
+include(AddCCompilerFlag)
+include(CheckCCompilerFlagSSP)
+
+if (UNIX)
+    #
+    # Check for -Werror turned on if possible
+    #
+    # This will prevent that compiler flags are detected incorrectly.
+    #
+    check_c_compiler_flag("-Werror" REQUIRED_FLAGS_WERROR)
+    if (REQUIRED_FLAGS_WERROR)
+        set(CMAKE_REQUIRED_FLAGS "-Werror")
+
+        if (PICKY_DEVELOPER)
+            list(APPEND SUPPORTED_COMPILER_FLAGS "-Werror")
+        endif()
+    endif()
+
+    add_c_compiler_flag("-std=gnu99" SUPPORTED_COMPILER_FLAGS)
+    #add_c_compiler_flag("-Wpedantic" SUPPORTED_COMPILER_FLAGS)
+    add_c_compiler_flag("-Wall" SUPPORTED_COMPILER_FLAGS)
+    add_c_compiler_flag("-Wshadow" SUPPORTED_COMPILER_FLAGS)
+    add_c_compiler_flag("-Wmissing-prototypes" SUPPORTED_COMPILER_FLAGS)
+    add_c_compiler_flag("-Wcast-align" SUPPORTED_COMPILER_FLAGS)
+    #add_c_compiler_flag("-Wcast-qual" SUPPORTED_COMPILER_FLAGS)
+    add_c_compiler_flag("-Werror=address" SUPPORTED_COMPILER_FLAGS)
+    add_c_compiler_flag("-Wstrict-prototypes" SUPPORTED_COMPILER_FLAGS)
+    add_c_compiler_flag("-Werror=strict-prototypes" SUPPORTED_COMPILER_FLAGS)
+    add_c_compiler_flag("-Wwrite-strings" SUPPORTED_COMPILER_FLAGS)
+    add_c_compiler_flag("-Werror=write-strings" SUPPORTED_COMPILER_FLAGS)
+    add_c_compiler_flag("-Werror-implicit-function-declaration" SUPPORTED_COMPILER_FLAGS)
+    add_c_compiler_flag("-Wpointer-arith" SUPPORTED_COMPILER_FLAGS)
+    add_c_compiler_flag("-Werror=pointer-arith" SUPPORTED_COMPILER_FLAGS)
+    add_c_compiler_flag("-Wdeclaration-after-statement" SUPPORTED_COMPILER_FLAGS)
+    add_c_compiler_flag("-Werror=declaration-after-statement" SUPPORTED_COMPILER_FLAGS)
+    add_c_compiler_flag("-Wreturn-type" SUPPORTED_COMPILER_FLAGS)
+    add_c_compiler_flag("-Werror=return-type" SUPPORTED_COMPILER_FLAGS)
+    add_c_compiler_flag("-Wuninitialized" SUPPORTED_COMPILER_FLAGS)
+    add_c_compiler_flag("-Werror=uninitialized" SUPPORTED_COMPILER_FLAGS)
+    add_c_compiler_flag("-Wimplicit-fallthrough" SUPPORTED_COMPILER_FLAGS)
+    add_c_compiler_flag("-Werror=strict-overflow" SUPPORTED_COMPILER_FLAGS)
+    add_c_compiler_flag("-Wstrict-overflow=2" SUPPORTED_COMPILER_FLAGS)
+    add_c_compiler_flag("-Wno-format-zero-length" SUPPORTED_COMPILER_FLAGS)
+
+    check_c_compiler_flag("-Wformat" REQUIRED_FLAGS_WFORMAT)
+    if (REQUIRED_FLAGS_WFORMAT)
+        list(APPEND SUPPORTED_COMPILER_FLAGS "-Wformat")
+        set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Wformat")
+    endif()
+    add_c_compiler_flag("-Wformat-security" SUPPORTED_COMPILER_FLAGS)
+    add_c_compiler_flag("-Werror=format-security" SUPPORTED_COMPILER_FLAGS)
+
+    # Allow zero for a variadic macro argument
+    string(TOLOWER "${CMAKE_C_COMPILER_ID}" _C_COMPILER_ID)
+    if ("${_C_COMPILER_ID}" STREQUAL "clang")
+        add_c_compiler_flag("-Wno-gnu-zero-variadic-macro-arguments" SUPPORTED_COMPILER_FLAGS)
+    endif()
+
+    add_c_compiler_flag("-fno-common" SUPPORTED_COMPILER_FLAGS)
+
+    if (CMAKE_BUILD_TYPE)
+        string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER)
+        if (CMAKE_BUILD_TYPE_LOWER MATCHES (release|relwithdebinfo|minsizerel))
+            add_c_compiler_flag("-Wp,-D_FORTIFY_SOURCE=2" SUPPORTED_COMPILER_FLAGS)
+        endif()
+    endif()
+
+    if (NOT SOLARIS)
+        check_c_compiler_flag_ssp("-fstack-protector-strong" WITH_STACK_PROTECTOR_STRONG)
+        if (WITH_STACK_PROTECTOR_STRONG)
+            list(APPEND SUPPORTED_COMPILER_FLAGS "-fstack-protector-strong")
+            # This is needed as Solaris has a seperate libssp
+            if (SOLARIS)
+                list(APPEND SUPPORTED_LINKER_FLAGS "-fstack-protector-strong")
+            endif()
+        else (WITH_STACK_PROTECTOR_STRONG)
+            check_c_compiler_flag_ssp("-fstack-protector" WITH_STACK_PROTECTOR)
+            if (WITH_STACK_PROTECTOR)
+                list(APPEND SUPPORTED_COMPILER_FLAGS "-fstack-protector")
+                # This is needed as Solaris has a seperate libssp
+                if (SOLARIS)
+                    list(APPEND SUPPORTED_LINKER_FLAGS "-fstack-protector")
+                endif()
+            endif()
+        endif (WITH_STACK_PROTECTOR_STRONG)
+
+        check_c_compiler_flag_ssp("-fstack-clash-protection" WITH_STACK_CLASH_PROTECTION)
+        if (WITH_STACK_CLASH_PROTECTION)
+            list(APPEND SUPPORTED_COMPILER_FLAGS "-fstack-clash-protection")
+        endif()
+    endif()
+
+    if (PICKY_DEVELOPER)
+        add_c_compiler_flag("-Wno-error=deprecated-declarations" SUPPORTED_COMPILER_FLAGS)
+        add_c_compiler_flag("-Wno-error=tautological-compare" SUPPORTED_COMPILER_FLAGS)
+    endif()
+
+    # Unset CMAKE_REQUIRED_FLAGS
+    unset(CMAKE_REQUIRED_FLAGS)
+endif()
+
+if (MSVC)
+    add_c_compiler_flag("/D _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES=1" SUPPORTED_COMPILER_FLAGS)
+    add_c_compiler_flag("/D _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT=1" SUPPORTED_COMPILER_FLAGS)
+    add_c_compiler_flag("/D _CRT_NONSTDC_NO_WARNINGS=1" SUPPORTED_COMPILER_FLAGS)
+    add_c_compiler_flag("/D _CRT_SECURE_NO_WARNINGS=1" SUPPORTED_COMPILER_FLAGS)
+endif()


-- 
pam wrapper repository



More information about the samba-cvs mailing list