-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
134 lines (119 loc) · 4.75 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
cmake_minimum_required (VERSION 3.8.0)
set(CMAKE_VERBOSE_MAKEFILE on)
project (ShenmueDK LANGUAGES CXX DESCRIPTION "Shenmue I & II HD Modding SDK for C++")
set(SHENDK_LIB_NAME ShenmueDK)
set(SHENDK_STATIC_LIB_NAME ShenmueDKStatic)
set(SHENDK_VERSION_MAJOR 0)
set(SHENDK_VERSION_MINOR 1)
set(SHENDK_VERSION_BUILD 0)
# c++ stuff
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_DEBUG_POSTFIX d)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
message("GCC")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -g0")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g3")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
message("MSVC")
set(CMAKE_CXX_FLAGS_RELEASE "/O2")
set(CMAKE_CXX_FLAGS_DEBUG "/O1")
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
message("Clang")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -g0")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g3")
else()
message(FATAL_ERROR "No support for this compiler yet!")
endif()
# options
option(BUILD_TESTS "Build test programs" ON)
option(BUILD_STATIC "Build shendk static library" ON)
option(BUILD_SHARED "Build shendk shared library" OFF)
# dependencies
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.0.0")
find_library(CXX_FILESYSTEM_SUPPORT NAMES stdc++fs)
endif()
# jsoncpp
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extern/jsoncpp)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/extern/jsoncpp/include)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/extern/jsoncpp/include)
# eigen3
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/extern/eigen3/cmake")
find_package(Eigen3 REQUIRED NO_MODULE)
include_directories(${EIGEN3_INCLUDE_DIR})
# zlib
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extern/zlib)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/extern/zlib)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/extern/zlib)
# tinyxml2
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extern/tinyxml2)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/extern/tinyxml2)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/extern/tinyxml2)
# devil
find_package(DevIL)
if (IL_FOUND)
message("DevIL already installed...")
else()
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extern/DevIL/src-IL)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extern/DevIL/src-ILU)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/extern/DevIL/include)
endif()
# FBX SDK
if(NOT DEFINED ENV{FBXSDK_ROOT})
message(FATAL_ERROR "FBXSDK_ROOT is not defined!")
else()
include_directories($ENV{FBXSDK_ROOT}/include)
include_directories($ENV{FBXSDK_ROOT}/lib)
endif()
# sources and stuff
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
file(GLOB_RECURSE HEADERS include/*.h include/*.hpp)
file(GLOB_RECURSE SOURCES src/*.cpp src/*.c src/*.h src/*.hpp)
# shendk shared library
if (BUILD_SHARED)
add_library(${SHENDK_LIB_NAME} SHARED ${SOURCES} ${HEADERS})
target_include_directories(${SHENDK_LIB_NAME}
PUBLIC include
PRIVATE src ${CMAKE_CURRENT_BINARY_DIR}
)
target_link_libraries (${SHENDK_LIB_NAME} Eigen3::Eigen)
target_link_libraries(${SHENDK_LIB_NAME} jsoncpp_lib)
target_link_libraries(${SHENDK_LIB_NAME} zlibstatic)
target_link_libraries(${SHENDK_LIB_NAME} tinyxml2)
target_link_libraries(${SHENDK_LIB_NAME} IL)
target_link_libraries(${SHENDK_LIB_NAME} ILU)
target_link_libraries(${SHENDK_LIB_NAME} libfbxsdk)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_link_libraries(${SHENDK_LIB_NAME} stdc++fs)
endif()
endif()
# shendk static library
if (BUILD_STATIC)
add_library(${SHENDK_STATIC_LIB_NAME} STATIC ${SOURCES} ${HEADERS})
target_include_directories(${SHENDK_STATIC_LIB_NAME}
PUBLIC include
PRIVATE src ${CMAKE_CURRENT_BINARY_DIR}
)
target_link_libraries (${SHENDK_STATIC_LIB_NAME} Eigen3::Eigen)
target_link_libraries(${SHENDK_STATIC_LIB_NAME} jsoncpp_lib)
target_link_libraries(${SHENDK_STATIC_LIB_NAME} zlibstatic)
target_link_libraries(${SHENDK_STATIC_LIB_NAME} tinyxml2)
target_link_libraries(${SHENDK_STATIC_LIB_NAME} IL)
target_link_libraries(${SHENDK_STATIC_LIB_NAME} ILU)
target_link_libraries(${SHENDK_STATIC_LIB_NAME} libfbxsdk)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_link_libraries(${SHENDK_STATIC_LIB_NAME} stdc++fs)
endif()
endif()
# unit tests (gtest)
if (BUILD_TESTS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extern/googletest)
include_directories(${GTEST_INCLUDE_DIRS})
file(GLOB_RECURSE TEST_SOURCES tests/UTest/*.cpp tests/UTest/*.h)
add_executable(shendk_test ${TEST_SOURCES})
target_link_libraries(shendk_test PRIVATE ${SHENDK_STATIC_LIB_NAME})
target_link_libraries(shendk_test PRIVATE ${CXX_FILESYSTEM_SUPPORT})
target_link_libraries(shendk_test PRIVATE gtest)
target_link_libraries(shendk_test PRIVATE gmock)
target_include_directories(shendk_test PRIVATE include)
endif()