[SCM] NSS Wrapper Repository - branch master updated
Andreas Schneider
asn at samba.org
Thu Feb 28 11:50:15 UTC 2019
The branch, master has been updated
via 7979c97 gitlab-ci: Setup CI for nss_wrapper
via baf74fc cmake: Use GNUInstallDirs
via 1d8fd4d cmake: Do not run test_nwrap_disabled with sanitizers
via 5e81a6f cmake: Disable source code execution when cross compiling
via 4846f43 cmake: Put defines in config.h
via 36fe8b5 cmake: Fix configure check for libdl
via f67c82e cmake: Use target_include_directories()
via dfdc976 cmake: Update AddCMockaTest.cmake
via 84df0f5 cmake: Update cmocka requirement
via 0d9bb5b cmake: Support running the tests with AddressSanitizer
via 43670a3 cmake: Add AddressSanitizer and UndefinedSanitizer
via 405b315 cmake: Move Compiler flags to new file
via 51da1fd cmake: Remove obsolete DefineCompilerFlags.cmake
via 5277cd0 cmake: Improve checks for compiler flags
via ae637af cmake: Update CMake defaults
via e03ec17 cmake: Do not misuse CMAKE_REQUIRED_LIBRARIES
via fda5618 cmake: Require at least cmake 3.5.0
via 4995ab1 tests: Fix strict aliasing issues in test_nwrap_disabled
via 98f7b80 tests: Fix sockaddr alignment issues in test_getaddrinfo
via f5f9a76 tests: Fix passwd entry for alice
via 205e3f2 nwrap: Fix copying 'struct passwd' on FreeBSD
via a0f38b4 nwrap: Rewrite nwrap_gr_copy_r() to take memory alignment into account
via fbb37b1 nwrap: Also check for NUL-byte in group loop
via 633e822 nwrap: Fix strict aliasing issue with sockaddr
via d0c03e3 nwrap: Fix strict aliasing issues
via 2eb9e76 nwrap: Use memcpy instead of strncpy
via 5c24605 README: Rename to a markdown file
from 05f50d2 Bump version to 1.1.5
https://git.samba.org/?p=nss_wrapper.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 7979c97d8bf10c54cbe422d191ddbb5cc0a2ae0e
Author: Andreas Schneider <asn at samba.org>
Date: Fri Feb 15 13:29:08 2019 +0100
gitlab-ci: Setup CI for nss_wrapper
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit baf74fcbb776f459ce0dc987210d01b1bb5e5d64
Author: Andreas Schneider <asn at samba.org>
Date: Wed Feb 20 10:35:27 2019 +0100
cmake: Use GNUInstallDirs
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 1d8fd4d1a5336df2bcebc8cde3a0a4f6ea8d6442
Author: Andreas Schneider <asn at samba.org>
Date: Fri Feb 15 13:54:31 2019 +0100
cmake: Do not run test_nwrap_disabled with sanitizers
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 5e81a6fc1f8677cd7708cd12f410f0626ee32178
Author: Andreas Schneider <asn at samba.org>
Date: Fri Feb 15 13:46:32 2019 +0100
cmake: Disable source code execution when cross compiling
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 4846f435eabba3c92adcf21a31e22f05d9232703
Author: Andreas Schneider <asn at samba.org>
Date: Fri Feb 15 13:45:12 2019 +0100
cmake: Put defines in config.h
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 36fe8b5c55f791154103a7aa3737261b6608b728
Author: Andreas Schneider <asn at samba.org>
Date: Fri Feb 15 13:26:42 2019 +0100
cmake: Fix configure check for libdl
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit f67c82ec074444b25b0c4f51013c9804ebd8aff3
Author: Andreas Schneider <asn at samba.org>
Date: Fri Feb 15 13:24:31 2019 +0100
cmake: Use target_include_directories()
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit dfdc976df864b8289185a5a4b0668544c78ddc2e
Author: Andreas Schneider <asn at samba.org>
Date: Fri Feb 15 12:13:18 2019 +0100
cmake: Update AddCMockaTest.cmake
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 84df0f5485e620bb4cdaa261925ac64e66935ba9
Author: Andreas Schneider <asn at samba.org>
Date: Fri Feb 15 12:05:18 2019 +0100
cmake: Update cmocka requirement
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 0d9bb5b5a5ec796333ab5827cc2c65a92dab60d1
Author: Andreas Schneider <asn at samba.org>
Date: Fri Feb 15 12:04:20 2019 +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 43670a36dc549a885becccbe79f556829243b674
Author: Andreas Schneider <asn at samba.org>
Date: Fri Feb 15 11:57:38 2019 +0100
cmake: Add AddressSanitizer and UndefinedSanitizer
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 405b3152e280bf8e27f55d5ec45484fc0165a777
Author: Andreas Schneider <asn at samba.org>
Date: Fri Feb 15 11:57:11 2019 +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 51da1fd9c3b57f385609ff8993b44c47e81d9e73
Author: Andreas Schneider <asn at samba.org>
Date: Fri Feb 15 11:54:55 2019 +0100
cmake: Remove obsolete DefineCompilerFlags.cmake
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 5277cd0ba11f2e3a92c2d4fafb9d855f3451dbec
Author: Andreas Schneider <asn at samba.org>
Date: Fri Feb 15 11:54:22 2019 +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 ae637af5fe56b95223f7f20e5df783a3dfed5612
Author: Andreas Schneider <asn at samba.org>
Date: Fri Feb 15 11:46:23 2019 +0100
cmake: Update CMake defaults
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit e03ec1742fb6772022557522314a840912e52e71
Author: Andreas Schneider <asn at samba.org>
Date: Fri Feb 15 11:44:39 2019 +0100
cmake: Do not misuse CMAKE_REQUIRED_LIBRARIES
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit fda5618f8cf6acb0bd2bc457d153a5e2d32a7261
Author: Andreas Schneider <asn at samba.org>
Date: Fri Feb 15 11:40:10 2019 +0100
cmake: Require at least cmake 3.5.0
We should use modern cmake.
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 4995ab1fe2c05bc96749b5e3db9c6b83c444c942
Author: Andreas Schneider <asn at samba.org>
Date: Fri Feb 15 15:20:35 2019 +0100
tests: Fix strict aliasing issues in test_nwrap_disabled
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 98f7b804de6b25eac2e25333f51d9bfa5ea53ca4
Author: Andreas Schneider <asn at samba.org>
Date: Fri Feb 15 14:51:07 2019 +0100
tests: Fix sockaddr alignment issues in test_getaddrinfo
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit f5f9a7619bab440d18fabbddedf63588f0594de6
Author: Andreas Schneider <asn at samba.org>
Date: Fri Feb 15 16:00:30 2019 +0100
tests: Fix passwd entry for alice
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 205e3f27b2b6c6890d503a413d72619cb817e154
Author: Andreas Schneider <asn at samba.org>
Date: Fri Feb 15 18:44:43 2019 +0100
nwrap: Fix copying 'struct passwd' on FreeBSD
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit a0f38b46a20b9d55bb67ce4e8d91eff8bcad0203
Author: Andreas Schneider <asn at samba.org>
Date: Fri Feb 15 18:03:51 2019 +0100
nwrap: Rewrite nwrap_gr_copy_r() to take memory alignment into account
Found by UndefinedSanitizer
tests/testsuite.c:288:43: runtime error: load of misaligned address
0x7fff50a89199 for type 'char *', which requires 8 byte alignment
0x7fff50a89199: note: pointer points here
79 00 78 00 00 00 00 00 00 00 00 00 fe 00 00 00 00 00 00 0c dc 8e e6 7a 7f 00 00 00 00 00 00 00
^
BUG: https://bugzilla.samba.org/show_bug.cgi?id=10667
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit fbb37b1fbc1bab4361aac258142257d353d082d8
Author: Andreas Schneider <asn at samba.org>
Date: Fri Feb 15 16:16:50 2019 +0100
nwrap: Also check for NUL-byte in group loop
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 633e822b128123ac62b2f4322c4215521e45e38a
Author: Andreas Schneider <asn at samba.org>
Date: Fri Feb 15 14:19:07 2019 +0100
nwrap: Fix strict aliasing issue with sockaddr
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit d0c03e3806a4b3d84e9cd1b0b7dd05fcfcb48c12
Author: Andreas Schneider <asn at samba.org>
Date: Fri Feb 15 14:04:43 2019 +0100
nwrap: Fix strict aliasing issues
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 2eb9e76879b755bcb9f0aa3477cb2baf3afc17a5
Author: Andreas Schneider <asn at samba.org>
Date: Fri Feb 15 14:00:15 2019 +0100
nwrap: Use memcpy instead of strncpy
This fixes compiler/analyzer warnings that the use of strncpy() is
unsafe.
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 5c2460581397a9dd5fab3520220c4bb79bb8e5a6
Author: Andreas Schneider <asn at samba.org>
Date: Mon Feb 18 11:14:59 2019 +0100
README: Rename to a markdown file
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
-----------------------------------------------------------------------
Summary of changes:
.gitlab-ci.yml | 231 ++++++++++++++++++++++++++++
CMakeLists.txt | 44 +++---
CPackConfig.cmake | 13 +-
CompilerChecks.cmake | 114 ++++++++++++++
ConfigureChecks.cmake | 146 +++++++++---------
README => README.md | 6 +-
cmake/Modules/AddCCompilerFlag.cmake | 21 +++
cmake/Modules/AddCMockaTest.cmake | 125 +++++++++++++--
cmake/Modules/CheckCCompilerFlagSSP.cmake | 36 ++++-
cmake/Modules/DefineCMakeDefaults.cmake | 15 +-
cmake/Modules/DefineCompilerFlags.cmake | 123 +++++----------
cmake/Modules/DefineInstallationPaths.cmake | 109 -------------
cmake/Modules/FindCMocka.cmake | 49 ------
cmake/Toolchain-Debian-mips.cmake | 21 +++
config.h.cmake | 7 +-
doc/CMakeLists.txt | 2 +-
nss_wrapper-config-version.cmake.in | 2 +-
nss_wrapper-config.cmake.in | 2 +-
nss_wrapper.pc.cmake | 6 +-
src/CMakeLists.txt | 27 ++--
src/nss_wrapper.c | 206 +++++++++++++++++--------
tests/CMakeLists.txt | 115 ++++++++++----
tests/passwd.in | 2 +-
tests/test_getaddrinfo.c | 127 +++++++++------
tests/test_nwrap_disabled.c | 9 +-
25 files changed, 1007 insertions(+), 551 deletions(-)
create mode 100644 .gitlab-ci.yml
create mode 100644 CompilerChecks.cmake
rename README => README.md (73%)
create mode 100644 cmake/Modules/AddCCompilerFlag.cmake
delete mode 100644 cmake/Modules/DefineInstallationPaths.cmake
delete mode 100644 cmake/Modules/FindCMocka.cmake
create mode 100644 cmake/Toolchain-Debian-mips.cmake
Changeset truncated at 500 lines:
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 0000000..699896e
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,231 @@
+variables:
+ BUILD_IMAGES_PROJECT: cmocka/gitlab-build-images
+ FEDORA_BUILD: buildenv-fedora
+ CENTOS7_BUILD: buildenv-centos7
+ TUMBLEWEED_BUILD: buildenv-tumbleweed
+ MINGW_BUILD: buildenv-mingw
+ DEBIAN_CROSS_BUILD: buildenv-debian-cross
+
+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_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/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
+ -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:
+ 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}~20")
+ 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}~20")
+
+ 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/nss_wrapper
+ - branches at cryptomilk/nss_wrapper
+ artifacts:
+ expire_in: 1 week
+ when: on_failure
+ paths:
+ - obj/
+
+.Debian.cross.template: &Debian_cross_template
+ stage: test
+ image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$DEBIAN_CROSS_BUILD
+ script:
+ - build=$(dpkg-architecture -qDEB_HOST_GNU_TYPE)
+ - host="${CI_JOB_NAME#*.cross.}"
+ - mkdir -p obj && cd obj && cmake
+ -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-Debian-mips.cmake
+ -DCMAKE_BUILD_TYPE=RelWithDebInfo
+ -DUNIT_TESTING=ON .. && make -j$(nproc) &&
+ ctest --output-on-failure
+ tags:
+ - shared
+ except:
+ - tags
+ artifacts:
+ expire_in: 1 week
+ when: on_failure
+ paths:
+ - obj/
+
+Debian.cross.mips-linux-gnu:
+ <<: *Debian_cross_template
+
+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 e91c266..4507a15 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,16 +1,20 @@
-project(nss_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")
-set(APPLICATION_VERSION_MAJOR "1")
-set(APPLICATION_VERSION_MINOR "1")
-set(APPLICATION_VERSION_PATCH "5")
+# Add defaults for cmake
+# Those need to be set before the project() call.
+include(DefineCMakeDefaults)
+include(DefineCompilerFlags)
-set(APPLICATION_VERSION "${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH}")
+project(nss_wrapper VERSION 1.1.5 LANGUAGES C)
+
+# global needed variables
+set(APPLICATION_NAME ${PROJECT_NAME})
# SOVERSION scheme: CURRENT.AGE.REVISION
# If there was an incompatible interface change:
@@ -22,18 +26,13 @@ set(APPLICATION_VERSION "${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINO
set(LIBRARY_VERSION "0.2.5")
set(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(DefineOptions.cmake)
include(CPackConfig.cmake)
+include(CompilerChecks.cmake)
+include(GNUInstallDirs)
# disallow in-source build
include(MacroEnsureOutOfSourceBuild)
@@ -50,14 +49,11 @@ configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
# check subdirectories
add_subdirectory(src)
-install(
- PROGRAMS
- nss_wrapper.pl
- DESTINATION
- ${BIN_INSTALL_DIR})
+install(PROGRAMS nss_wrapper.pl
+ DESTINATION ${CMAKE_INSTALL_BINDIR})
if (UNIT_TESTING)
- find_package(CMocka REQUIRED)
+ find_package(cmocka 1.1.0 REQUIRED)
file(TO_CMAKE_PATH "${CMAKE_SOURCE_DIR}/tests/valgrind.supp" VALGRIND_SUPPRESSION_FILE)
# add the valgrind suppressions
@@ -79,7 +75,7 @@ install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/nss_wrapper.pc
DESTINATION
- ${LIB_INSTALL_DIR}/pkgconfig
+ ${CMAKE_INSTALL_LIBDIR}/pkgconfig
COMPONENT
pkgconfig
)
@@ -92,7 +88,7 @@ install(
${CMAKE_CURRENT_BINARY_DIR}/nss_wrapper-config-version.cmake
${CMAKE_CURRENT_BINARY_DIR}/nss_wrapper-config.cmake
DESTINATION
- ${CMAKE_INSTALL_DIR}/nss_wrapper
+ ${CMAKE_INSTALL_LIBDIR}/cmake/nss_wrapper
COMPONENT
devel
)
diff --git a/CPackConfig.cmake b/CPackConfig.cmake
index e1b83ac..827b518 100644
--- a/CPackConfig.cmake
+++ b/CPackConfig.cmake
@@ -2,20 +2,15 @@
# 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 SSH library")
-set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README")
+set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.md")
set(CPACK_PACKAGE_VENDOR "The SSH Library Development 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")
@@ -37,7 +32,7 @@ endif (WIN32)
set(CPACK_PACKAGE_INSTALL_DIRECTORY "libssh")
-set(CPACK_PACKAGE_FILE_NAME ${APPLICATION_NAME}-${CPACK_PACKAGE_VERSION})
+set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION})
set(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Libraries")
set(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C/C++ Headers")
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()
+
+if (SUPPORTED_COMPILER_FLAGS)
+ set(DEFAULT_C_COMPILE_FLAGS ${SUPPORTED_COMPILER_FLAGS} CACHE INTERNAL "Default C Compiler Flags" FORCE)
+endif()
+if (SUPPORTED_LINKER_FLAGS)
+ set(DEFAULT_LINK_FLAGS ${SUPPORTED_LINKER_FLAGS} CACHE INTERNAL "Default C Linker Flags" FORCE)
+endif()
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 41029d4..d0e1e0d 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -8,8 +8,8 @@ include(CheckPrototypeDefinition)
include(TestBigEndian)
include(CheckCSourceRuns)
-set(PACKAGE ${APPLICATION_NAME})
-set(VERSION ${APPLICATION_VERSION})
+set(PACKAGE ${PROJECT_NAME})
+set(VERSION ${PROJECT_VERSION})
set(DATADIR ${DATA_INSTALL_DIR})
set(LIBDIR ${LIB_INSTALL_DIR})
set(PLUGINDIR "${PLUGIN_INSTALL_DIR}-${LIBRARY_SOVERSION}")
--
NSS Wrapper Repository
More information about the samba-cvs
mailing list