Baptiste Lepilleur | eafd702 | 2013-05-08 20:21:11 +0000 | [diff] [blame] | 1 | CMAKE_MINIMUM_REQUIRED(VERSION 2.6) |
| 2 | PROJECT(jsoncpp) |
| 3 | ENABLE_TESTING() |
| 4 | |
| 5 | OPTION(JSONCPP_WITH_TESTS "Compile and run JsonCpp test executables" ON) |
| 6 | OPTION(JSONCPP_WITH_POST_BUILD_UNITTEST "Automatically run unit-tests as a post build step" ON) |
Baptiste Lepilleur | 700b380 | 2013-05-09 18:42:33 +0000 | [diff] [blame] | 7 | OPTION(JSONCPP_WITH_WARNING_AS_ERROR "Force compilation to fail if a warning occurs" OFF) |
Baptiste Lepilleur | eafd702 | 2013-05-08 20:21:11 +0000 | [diff] [blame] | 8 | |
| 9 | # Ensures that CMAKE_BUILD_TYPE is visible in cmake-gui on Unix |
| 10 | IF(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) |
| 16 | ENDIF(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. |
| 20 | SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib |
| 21 | CACHE PATH "Single directory for all static libraries.") |
| 22 | SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib |
| 23 | CACHE PATH "Single directory for all dynamic libraries on Unix.") |
| 24 | SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin |
| 25 | CACHE PATH "Single directory for all executable and dynamic libraries on Windows.") |
| 26 | MARK_AS_ADVANCED( CMAKE_RUNTIME_OUTPUT_DIRECTORY CMAKE_LIBRARY_OUTPUT_DIRECTORY CMAKE_ARCHIVE_OUTPUT_DIRECTORY ) |
| 27 | |
| 28 | # Set variable named ${VAR_NAME} to value ${VALUE} |
| 29 | FUNCTION(set_using_dynamic_name VAR_NAME VALUE) |
| 30 | SET( "${VAR_NAME}" "${VALUE}" PARENT_SCOPE) |
| 31 | ENDFUNCTION(set_using_dynamic_name) |
| 32 | |
Baptiste Lepilleur | 700b380 | 2013-05-09 18:42:33 +0000 | [diff] [blame] | 33 | macro(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 ) |
| 39 | endmacro() |
| 40 | |
Baptiste Lepilleur | eafd702 | 2013-05-08 20:21:11 +0000 | [diff] [blame] | 41 | # Include our configuration header |
Aleksandr Derbenev | b3deb61 | 2014-08-09 22:21:33 +0400 | [diff] [blame] | 42 | INCLUDE_DIRECTORIES( ${jsoncpp_SOURCE_DIR}/include ) |
Baptiste Lepilleur | eafd702 | 2013-05-08 20:21:11 +0000 | [diff] [blame] | 43 | |
Baptiste Lepilleur | 700b380 | 2013-05-09 18:42:33 +0000 | [diff] [blame] | 44 | if ( 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 ") |
| 48 | endif( MSVC ) |
| 49 | |
| 50 | IF(JSONCPP_WITH_WARNING_AS_ERROR) |
| 51 | UseCompilationWarningAsError() |
| 52 | ENDIF(JSONCPP_WITH_WARNING_AS_ERROR) |
| 53 | |
Baptiste Lepilleur | eafd702 | 2013-05-08 20:21:11 +0000 | [diff] [blame] | 54 | # Build the different applications |
| 55 | ADD_SUBDIRECTORY( src ) |
| 56 | |
| 57 | #install the includes |
| 58 | ADD_SUBDIRECTORY( include ) |