blob: eef9aaa12e5f7d7374be974a76f606d03bb3d17a [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)
Jonas Platte62708582014-09-14 15:45:07 +02008OPTION(JSONCPP_WITH_PKGCONFIG_SUPPORT "Generate and install .pc files" ON)
Baptiste Lepilleureafd7022013-05-08 20:21:11 +00009
10# Ensures that CMAKE_BUILD_TYPE is visible in cmake-gui on Unix
11IF(NOT WIN32)
12 IF(NOT CMAKE_BUILD_TYPE)
13 SET(CMAKE_BUILD_TYPE Release CACHE STRING
14 "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel Coverage."
15 FORCE)
16 ENDIF(NOT CMAKE_BUILD_TYPE)
17ENDIF(NOT WIN32)
18
19# This ensures shared DLL are in the same dir as executable on Windows.
20# Put all executables / libraries are in a project global directory.
21SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib
22 CACHE PATH "Single directory for all static libraries.")
23SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib
24 CACHE PATH "Single directory for all dynamic libraries on Unix.")
25SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin
26 CACHE PATH "Single directory for all executable and dynamic libraries on Windows.")
27MARK_AS_ADVANCED( CMAKE_RUNTIME_OUTPUT_DIRECTORY CMAKE_LIBRARY_OUTPUT_DIRECTORY CMAKE_ARCHIVE_OUTPUT_DIRECTORY )
28
29# Set variable named ${VAR_NAME} to value ${VALUE}
30FUNCTION(set_using_dynamic_name VAR_NAME VALUE)
31 SET( "${VAR_NAME}" "${VALUE}" PARENT_SCOPE)
32ENDFUNCTION(set_using_dynamic_name)
33
Baptiste Lepilleur700b3802013-05-09 18:42:33 +000034macro(UseCompilationWarningAsError)
35 if ( MSVC )
36 # Only enabled in debug because some old versions of VS STL generate
37 # warnings when compiled in release configuration.
38 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /WX ")
39 endif( MSVC )
40endmacro()
41
Baptiste Lepilleureafd7022013-05-08 20:21:11 +000042# Include our configuration header
Aleksandr Derbenevb3deb612014-08-09 22:21:33 +040043INCLUDE_DIRECTORIES( ${jsoncpp_SOURCE_DIR}/include )
Baptiste Lepilleureafd7022013-05-08 20:21:11 +000044
Baptiste Lepilleur700b3802013-05-09 18:42:33 +000045if ( MSVC )
46 # Only enabled in debug because some old versions of VS STL generate
47 # unreachable code warning when compiled in release configuration.
48 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /W4 ")
49endif( MSVC )
50
51IF(JSONCPP_WITH_WARNING_AS_ERROR)
52 UseCompilationWarningAsError()
53ENDIF(JSONCPP_WITH_WARNING_AS_ERROR)
54
Jonas Platte62708582014-09-14 15:45:07 +020055IF(JSONCPP_WITH_PKGCONFIG_SUPPORT)
56 CONFIGURE_FILE(
57 "pkg-config/jsoncpp.pc.in"
58 "pkg-config/jsoncpp.pc"
59 @ONLY)
60 INSTALL(FILES "${CMAKE_BINARY_DIR}/pkg-config/jsoncpp.pc"
61 DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig")
62ENDIF(JSONCPP_WITH_PKGCONFIG_SUPPORT)
63
Baptiste Lepilleureafd7022013-05-08 20:21:11 +000064# Build the different applications
65ADD_SUBDIRECTORY( src )
66
67#install the includes
68ADD_SUBDIRECTORY( include )