CMakeLists.txt 2 KB
Newer Older
1
cmake_minimum_required( VERSION 2.8.7 )
2 3 4 5 6 7 8 9

project( simmc-agent )

# version number
set ( VERSION_MAJOR 0 )
set ( VERSION_MINOR 0 )

# cpr requires c++11
10
if(WIN32)
11 12
	add_definitions( -DBOOST_ALL_NO_LIB )
	set(Boost_USE_STATIC_LIBS ON)
13
	add_definitions(-DCURL_STATICLIB)
14 15
	add_definitions(-D_CRT_SECURE_NO_WARNINGS)
	add_definitions(-D_WIN32_WINNT=0x0501)
16 17 18 19 20
    # add_compile_options("/std:c++11")
    # set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++11)
else()
    set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11" )
    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++ -static-libgcc")
21
endif()
22

23
# src : main, collect functions  + jsoncpp library
24
file ( GLOB SOURCES src/agent/*.cpp )
25

26
# src : curl requests
27 28 29 30 31 32 33 34 35

# options for cpr
# avoid experimental use of openssl
option( CMAKE_USE_OPENSSL "Use OpenSSL code. Experimental" OFF )
# avoid building tests
option( BUILD_CPR_TESTS "Set to ON to build cpr tests." OFF )

# options for curl
# avoid building tests
36
option( BUILD_CURL_TESTS "Set to ON to build cURL tests." OFF )
37
# avoid running tests - set ON again in download version or if errors occur
38
option( RUN_CURL_TESTS "Set to ON to run cURL tests." OFF )
39
option( CURL_STATICLIB "Set to ON to generated curl statically." ON )
40 41

add_subdirectory ( lib/cpr )
42
include_directories ( ${CURL_INCLUDE_DIRS} )
43

44
# headers
45
include_directories ( "include" )
46 47

# include headers from boost lib
48
include_directories ( "${CMAKE_BINARY_DIR}/include" )
49
include_directories ( "${CMAKE_BINARY_DIR}/Boost/src/Boost" )
50

51 52 53
# scr = libboost
include ( "modules/boost.cmake" )

54 55
# compile
set ( CMAKE_RUNTIME_OUTPUT_DIRECTORY "../bin" )
56
add_executable ( agent-v${VERSION_MAJOR}.${VERSION_MINOR} ${SOURCES} )
57
target_link_libraries ( agent-v${VERSION_MAJOR}.${VERSION_MINOR} ${CURL_LIBRARIES} ${FILESYSTEM_LIB} ${SYSTEM_LIB} ${REGEX_LIB} ${PROGRAM_OPTIONS_LIB} ${CROSS_STATIC} )
58

59
add_dependencies ( agent-v${VERSION_MAJOR}.${VERSION_MINOR} Boost)
60

61
if ( UNIX )
62 63 64
    # libudev
    target_link_libraries ( agent-v${VERSION_MAJOR}.${VERSION_MINOR} udev )
endif ()