|
| 1 | +cmake_minimum_required( VERSION 2.8.12 ) |
| 2 | + |
| 3 | +project( json_to_cpp_prj ) |
| 4 | + |
| 5 | +include( ExternalProject ) |
| 6 | + |
| 7 | +find_package( Boost 1.58.0 COMPONENTS system date_time iostreams program_options filesystem regex unit_test_framework REQUIRED ) |
| 8 | + |
| 9 | +enable_testing( ) |
| 10 | +add_definitions( -DBOOST_TEST_DYN_LINK ) |
| 11 | + |
| 12 | +find_package( Threads REQUIRED ) |
| 13 | + |
| 14 | +if( ${CMAKE_CXX_COMPILER_ID} STREQUAL 'MSVC' ) |
| 15 | + add_compile_options( -D_WIN32_WINNT=0x0601 ) |
| 16 | +else( ) |
| 17 | + if( ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" ) |
| 18 | + add_compile_options(-std=c++14 -Weverything -pthread -Wno-c++98-compat -g -Wno-covered-switch-default -Wno-padded -Wno-exit-time-destructors -Wno-c++98-compat-pedantic -Wno-unused-parameter -Wno-missing-noreturn -Wno-missing-prototypes -Wno-disabled-macro-expansion -Wno-c99-compat) |
| 19 | + elseif( ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" ) |
| 20 | + add_compile_options(-std=c++14 -ggdb -Wall -pthread -Wno-deprecated-declarations -march=native ) |
| 21 | + endif( ) |
| 22 | +endif( ) |
| 23 | + |
| 24 | +externalproject_add( |
| 25 | + header_libraries_prj |
| 26 | + GIT_REPOSITORY "https://github.com/beached/header_libraries.git" |
| 27 | + SOURCE_DIR "${CMAKE_BINARY_DIR}/dependencies/header_libraries" |
| 28 | + GIT_TAG "master" |
| 29 | + INSTALL_DIR "${CMAKE_BINARY_DIR}/install" |
| 30 | + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/install |
| 31 | +) |
| 32 | + |
| 33 | +externalproject_add( |
| 34 | + parse_json_prj |
| 35 | + GIT_REPOSITORY "https://github.com/beached/parse_json.git" |
| 36 | + SOURCE_DIR "${CMAKE_BINARY_DIR}/dependencies/parse_json" |
| 37 | + GIT_TAG "master" |
| 38 | + INSTALL_DIR "${CMAKE_BINARY_DIR}/install" |
| 39 | + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/install |
| 40 | +) |
| 41 | + |
| 42 | +externalproject_add( |
| 43 | + char_range_prj |
| 44 | + GIT_REPOSITORY "https://github.com/beached/char_range.git" |
| 45 | + SOURCE_DIR "${CMAKE_BINARY_DIR}/dependencies/char_range" |
| 46 | + GIT_TAG "master" |
| 47 | + INSTALL_DIR "${CMAKE_BINARY_DIR}/install" |
| 48 | + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/install |
| 49 | +) |
| 50 | + |
| 51 | +externalproject_add( |
| 52 | + date_prj |
| 53 | + GIT_REPOSITORY "https://github.com/beached/date.git" |
| 54 | + SOURCE_DIR "${CMAKE_BINARY_DIR}/dependencies/date" |
| 55 | + GIT_TAG "master" |
| 56 | + INSTALL_DIR "${CMAKE_BINARY_DIR}/install" |
| 57 | + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/install |
| 58 | +) |
| 59 | + |
| 60 | +set( HEADER_FOLDER "include" ) |
| 61 | +set( SOURCE_FOLDER "src" ) |
| 62 | +set( TEST_FOLDER "tests" ) |
| 63 | + |
| 64 | +include_directories( SYSTEM "${CMAKE_BINARY_DIR}/install/include" ) |
| 65 | +include_directories( ${HEADER_FOLDER} ) |
| 66 | +include_directories( SYSTEM ${OPENSSL_INCLUDE_DIR} ) |
| 67 | + |
| 68 | +include_directories( SYSTEM ${Boost_INCLUDE_DIRS} ) |
| 69 | + |
| 70 | +link_directories( "${CMAKE_BINARY_DIR}/install/lib" ) |
| 71 | +link_directories( ${Boost_LIBRARY_DIRS} ) |
| 72 | + |
| 73 | +set( HEADER_FILES |
| 74 | + ${HEADER_FOLDER}/json_to_cpp.h |
| 75 | +) |
| 76 | + |
| 77 | +set( SOURCE_FILES |
| 78 | + ${SOURCE_FOLDER}/json_to_cpp.cpp |
| 79 | +) |
| 80 | + |
| 81 | +add_library( json_to_cpp ${HEADER_FILES} ${SOURCE_FILES} ) |
| 82 | +add_dependencies( json_to_cpp header_libraries_prj parse_json_prj char_range_prj date_prj ) |
| 83 | +target_link_libraries( json_to_cpp parse_json tz char_range ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ) |
| 84 | + |
| 85 | +add_executable( json_to_cpp_bin ${HEADER_FILES} ${SOURCE_FOLDER}/main.cpp ) |
| 86 | +target_link_libraries( json_to_cpp_bin json_to_cpp parse_json char_range ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ) |
| 87 | + |
| 88 | +install( TARGETS json_to_cpp DESTINATION lib ) |
| 89 | +install( TARGETS json_to_cpp_bin DESTINATION bin ) |
| 90 | +install( DIRECTORY ${HEADER_FOLDER}/ DESTINATION include/daw/json_to_cpp ) |
0 commit comments