forked from modio/modio-sdk-legacy
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
97 lines (79 loc) · 2.92 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
cmake_minimum_required(VERSION 3.5)
project(modio)
set (CMAKE_CXX_STANDARD 11)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
# set BUILD_SHARED_LIBs to OFF to compile statically, for example:
# cmake -D BUILD_SHARED_LIBS=OFF .
option(BUILD_SHARED_LIBS "Build Shared Libraries" ON)
# MSVC: set the crtmode flag to 'static' to include the Visual C++
# runtime statically. Requires libcurl to be built with /MT as well.
# cmake -D crtmode=static .
include_directories(include additional_dependencies include/dependencies/miniz)
file(GLOB_RECURSE SOURCES "src/*.cpp" "src/*.c")
add_library(modio ${SOURCES})
if( BUILD_SHARED_LIBS )
message("Building mod.io SDK dynamically")
add_definitions(-DMODIO_DYNAMICLIB -DCURL_STATICLIB)
else()
message("Building mod.io SDK statically")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
add_definitions(-DMODIO_STATICLIB -DCURL_STATICLIB)
endif()
IF (APPLE)
find_package(CURL REQUIRED)
target_link_libraries(modio ${CURL_LIBRARIES})
ENDIF()
IF (UNIX AND NOT APPLE)
add_definitions(-D_LARGEFILE64_SOURCE)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
target_link_libraries (modio curl)
ENDIF ()
IF (MINGW)
target_link_libraries(modio
${CMAKE_SOURCE_DIR}/lib/MinGW/libcurl.a
${CMAKE_SOURCE_DIR}/lib/MinGW/libcrypto.dll.a
${CMAKE_SOURCE_DIR}/lib/MinGW/libeay32.dll
${CMAKE_SOURCE_DIR}/lib/MinGW/libssl.dll.a
wldap32 ws2_32)
ENDIF()
IF (MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS -DUNICODE -D_UNICODE)
target_link_libraries(modio ws2_32.lib wldap32.lib advapi32.lib kernel32.lib comdlg32.lib crypt32.lib normaliz.lib )
IF (crtmode AND crtmode STREQUAL "static")
set(CompilerFlags
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_RELEASE
CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE
)
foreach(CompilerFlag ${CompilerFlags})
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
endforeach()
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
target_link_libraries(modio ${CMAKE_SOURCE_DIR}/lib/MSVC/x64/static/libcurl_a.lib)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
target_link_libraries(modio ${CMAKE_SOURCE_DIR}/lib/MSVC/x86/static/libcurl_a.lib)
endif()
ELSE()
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
target_link_libraries(modio ${CMAKE_SOURCE_DIR}/lib/MSVC/x64/libcurl_a.lib)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
target_link_libraries(modio ${CMAKE_SOURCE_DIR}/lib/MSVC/x86/libcurl_a.lib)
endif()
ENDIF()
ENDIF()
IF( test AND test STREQUAL "on" )
message("Testing enabled")
file(GLOB TEST_SRC_FILES ${PROJECT_SOURCE_DIR}/test/*.cpp)
add_subdirectory(ext/googletest-master)
enable_testing()
include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
add_executable(runUnitTests ${TEST_SRC_FILES})
target_link_libraries(runUnitTests gtest gtest_main modio)
add_test(UnitTests runUnitTests)
ENDIF()