diff CMakeLists.txt @ 834:8081ed84589d

Use static nss from subrepository on windows
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 28 Jul 2014 13:03:45 +0200
parents 3a9b0c75f5a6
children 3ae7ad044566
line wrap: on
line diff
--- a/CMakeLists.txt	Mon Jul 28 13:03:00 2014 +0200
+++ b/CMakeLists.txt	Mon Jul 28 13:03:45 2014 +0200
@@ -36,7 +36,17 @@
 
 find_package(Qt5Widgets)
 
-find_package(NSS)
+if (NOT WIN32)
+   find_package(NSS)
+else ()
+   # Use static NSS for Windows
+   if (NOT EXISTS "${CMAKE_SOURCE_DIR}/nss-cmake-static")
+      MESSAGE(FATAL_ERROR "Could not find nss-cmake-static checkout. Please run: \n hg clone https://wald.intevation.org/hg/trustbridge/nss-cmake-static '${CMAKE_SOURCE_DIR}/nss-cmake-static'")
+   endif()
+  set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/nss-cmake-static/")
+  set(NSS_STATIC_PATH "${CMAKE_SOURCE_DIR}/nss-cmake-static")
+  include (nss-cmake-static)
+endif()
 
 # Use cmake's automoc and make sure the generated files are included
 set(CMAKE_AUTOMOC ON)
@@ -60,7 +70,7 @@
 set(WARN_HARDENING_FLAGS " -Wextra -Wconversion -Wformat-security")
 
 # Hardening flags
-set(HARDENING_FLAGS " -Wall -Werror -fstack-protector-all -fno-exceptions")
+set(HARDENING_FLAGS " -Wall -fstack-protector-all -fno-exceptions")
 set(HARDENING_FLAGS " ${HARDENING_FLAGS} -Wstack-protector")
 set(HARDENING_FLAGS " ${HARDENING_FLAGS} --param ssp-buffer-size=4")
 set(HARDENING_FLAGS " ${HARDENING_FLAGS} -D_FORTIFY_SOURCE=2 -O0")
@@ -99,6 +109,15 @@
     add_dependencies(static_check flawfinder)
 endif (FLAWFINDER_PATH)
 
+if(WIN32)
+  add_subdirectory(nss-cmake-static)
+  add_definitions(-D_WIN32_WINNT=0x0600) # Windows vista. NSS defines its own winver.
+endif()
+
+# No chance to compile nss with -Werror
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
+
 add_subdirectory(common)
 
 add_subdirectory(cinst)
@@ -113,10 +132,6 @@
 add_subdirectory(doc)
 
 # Configure packaging script for testing
-list(GET NSS_LIBRARIES 1 NSS_BASE_DIR)
-get_filename_component(NSS_BASE_DIR ${NSS_BASE_DIR} PATH)
-
-set(NSS_BASE_DIR "${NSS_BASE_DIR}/..")
 configure_file (packaging/tmp-createpackage.sh.in packaging/tmp-createpackage.sh @ONLY)
 configure_file (packaging/create-dist-package.sh.in packaging/create-dist-package.sh @ONLY)
 configure_file (packaging/linux-createpackage.sh.in packaging/linux-createpackage.sh @ONLY)

http://wald.intevation.org/projects/trustbridge/