aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetri Lehtinen <petri@digip.org>2013-06-25 11:30:39 -0700
committerPetri Lehtinen <petri@digip.org>2013-06-25 11:30:39 -0700
commit84b5bfe173283695e7a07ca7da991047a7c4b25c (patch)
treea43a57dab31e5c71eb1f1b3040892814c3aceb79
parent68e201add8f856e81fe0fe116adebe2d344cbfa8 (diff)
parentd9ee5a7f1b740ed04f7301ec83ae8aeb3076fef5 (diff)
downloadjansson-84b5bfe173283695e7a07ca7da991047a7c4b25c.zip
jansson-84b5bfe173283695e7a07ca7da991047a7c4b25c.tar.gz
jansson-84b5bfe173283695e7a07ca7da991047a7c4b25c.tar.bz2
Merge pull request #127 from cryptobiote/master
Adding option for MSVC for those who are linking statically.
-rw-r--r--CMakeLists.txt23
1 files changed, 19 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index cdad582..e4afb2e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -53,6 +53,12 @@ project (jansson C)
# Options
OPTION (BUILD_SHARED_LIBS "Build shared libraries." OFF)
+if (MSVC)
+ # This option must match the settings used in your program, in particular if you
+ # are linking statically
+ OPTION( STATIC_CRT "Link the static CRT libraries" OFF )
+endif ()
+
# Set some nicer output dirs.
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
@@ -61,10 +67,10 @@ SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
# Give the debug version a different postfix for windows,
# so both the debug and release version can be built in the
# same build-tree on Windows (MSVC).
-IF (WIN32)
+if (WIN32)
SET (CMAKE_DEBUG_POSTFIX "_d")
-ELSE (WIN32)
-ENDIF (WIN32)
+else (WIN32)
+endif (WIN32)
# This is how I thought it should go
# set (JANSSON_VERSION "2.3.1")
@@ -84,15 +90,24 @@ include (CheckFunctionKeywords)
include (CheckIncludeFiles)
include (CheckTypeSize)
-# Turn off Microsofts "security" warnings.
+
if (MSVC)
+ # Turn off Microsofts "security" warnings.
add_definitions( "/W3 /D_CRT_SECURE_NO_WARNINGS /wd4005 /wd4996 /nologo" )
+
+ if (STATIC_CRT)
+ set(CMAKE_C_FLAGS_RELEASE "/MT")
+ set(CMAKE_C_FLAGS_DEBUG "/MTd")
+ endif()
+
endif()
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_C_FLAGS "-fPIC")
endif()
+
+
# Check for the int-type includes
check_include_files (sys/types.h HAVE_SYS_TYPES_H)
check_include_files (inttypes.h HAVE_INTTYPES_H)