blob: 85e954e39ad17bfe606f4fbcb072eb0a54dd02ea [file] [log] [blame]
Baptiste Lepilleureafd7022013-05-08 20:21:11 +00001CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
2PROJECT(jsoncpp)
3ENABLE_TESTING()
4
5OPTION(JSONCPP_WITH_TESTS "Compile and run JsonCpp test executables" ON)
6OPTION(JSONCPP_WITH_POST_BUILD_UNITTEST "Automatically run unit-tests as a post build step" ON)
Baptiste Lepilleur700b3802013-05-09 18:42:33 +00007OPTION(JSONCPP_WITH_WARNING_AS_ERROR "Force compilation to fail if a warning occurs" OFF)
Baptiste Lepilleureafd7022013-05-08 20:21:11 +00008
9# Ensures that CMAKE_BUILD_TYPE is visible in cmake-gui on Unix
10IF(NOT WIN32)
11 IF(NOT CMAKE_BUILD_TYPE)
12 SET(CMAKE_BUILD_TYPE Release CACHE STRING
13 "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel Coverage."
14 FORCE)
15 ENDIF(NOT CMAKE_BUILD_TYPE)
16ENDIF(NOT WIN32)
17
18# This ensures shared DLL are in the same dir as executable on Windows.
19# Put all executables / libraries are in a project global directory.
20SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib
21 CACHE PATH "Single directory for all static libraries.")
22SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib
23 CACHE PATH "Single directory for all dynamic libraries on Unix.")
24SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin
25 CACHE PATH "Single directory for all executable and dynamic libraries on Windows.")
26MARK_AS_ADVANCED( CMAKE_RUNTIME_OUTPUT_DIRECTORY CMAKE_LIBRARY_OUTPUT_DIRECTORY CMAKE_ARCHIVE_OUTPUT_DIRECTORY )
27
28# Set variable named ${VAR_NAME} to value ${VALUE}
29FUNCTION(set_using_dynamic_name VAR_NAME VALUE)
30 SET( "${VAR_NAME}" "${VALUE}" PARENT_SCOPE)
31ENDFUNCTION(set_using_dynamic_name)
32
Baptiste Lepilleur700b3802013-05-09 18:42:33 +000033macro(UseCompilationWarningAsError)
34 if ( MSVC )
35 # Only enabled in debug because some old versions of VS STL generate
36 # warnings when compiled in release configuration.
37 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /WX ")
38 endif( MSVC )
39endmacro()
40
Baptiste Lepilleureafd7022013-05-08 20:21:11 +000041# Include our configuration header
Aleksandr Derbenevb3deb612014-08-09 22:21:33 +040042INCLUDE_DIRECTORIES( ${jsoncpp_SOURCE_DIR}/include )
Baptiste Lepilleureafd7022013-05-08 20:21:11 +000043
Baptiste Lepilleur700b3802013-05-09 18:42:33 +000044if ( MSVC )
45 # Only enabled in debug because some old versions of VS STL generate
46 # unreachable code warning when compiled in release configuration.
47 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /W4 ")
48endif( MSVC )
49
50IF(JSONCPP_WITH_WARNING_AS_ERROR)
51 UseCompilationWarningAsError()
52ENDIF(JSONCPP_WITH_WARNING_AS_ERROR)
53
Baptiste Lepilleureafd7022013-05-08 20:21:11 +000054# Build the different applications
55ADD_SUBDIRECTORY( src )
56
57#install the includes
58ADD_SUBDIRECTORY( include )