-
Notifications
You must be signed in to change notification settings - Fork 12
/
CMakeLists.txt
159 lines (137 loc) · 5.72 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
cmake_minimum_required(VERSION 3.21)
include(${CMAKE_ROOT}/Modules/ExternalProject.cmake)
message("Using CMake version ${CMAKE_VERSION}")
# for CCACHE
if(APPLE)
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
endif()
endif()
project(
Anim
LANGUAGES CXX
VERSION 0.1.0)
set(CMAKE_CXX_STANDARD 17)
# for ninja(unix)
if (UNIX AND NOT APPLE)
set(CMAKE_MAKE_PROGRAM /usr/bin/ninja CACHE FILEPATH "")
endif()
message("CMAKE_RUNTIME_OUTPUT_DIRECTORY : ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
message("CMAKE_BINARY_DIR : ${CMAKE_BINARY_DIR}")
# for apple ccache
if(APPLE)
get_property(RULE_LAUNCH_COMPILE GLOBAL PROPERTY RULE_LAUNCH_COMPILE)
if(RULE_LAUNCH_COMPILE AND CMAKE_GENERATOR STREQUAL "Xcode")
# Set up wrapper scripts
configure_file(launch-c.in launch-c)
configure_file(launch-cxx.in launch-cxx)
execute_process(COMMAND chmod a+rx
"${CMAKE_BINARY_DIR}/launch-c"
"${CMAKE_BINARY_DIR}/launch-cxx"
)
# Set Xcode project attributes to route compilation and linking
# through our scripts
set(CMAKE_XCODE_ATTRIBUTE_CC "${CMAKE_BINARY_DIR}/launch-c")
set(CMAKE_XCODE_ATTRIBUTE_CXX "${CMAKE_BINARY_DIR}/launch-cxx")
set(CMAKE_XCODE_ATTRIBUTE_LD "${CMAKE_BINARY_DIR}/launch-c")
set(CMAKE_XCODE_ATTRIBUTE_LDPLUSPLUS "${CMAKE_BINARY_DIR}/launch-cxx")
endif()
endif()
# for output directory
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
file(COPY resources DESTINATION ${CMAKE_BINARY_DIR}/bin)
file(COPY imgui.ini DESTINATION ${CMAKE_BINARY_DIR}/bin)
file(COPY LICENSE DESTINATION ${CMAKE_BINARY_DIR}/bin)
message("==========================================================")
message("Build python")
if (APPLE)
execute_process(COMMAND sh "scripts/build_python_osx.sh" WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
if (NOT EXISTS ${CMAKE_BINARY_DIR}/bin/python/bin/python)
file(COPY ${CMAKE_CURRENT_LIST_DIR}/python DESTINATION ${CMAKE_BINARY_DIR}/bin)
endif()
file(COPY mp_mocap DESTINATION ${CMAKE_BINARY_DIR}/bin/python/lib/python3.10/site-packages)
elseif(WIN32)
execute_process(COMMAND cmd /C ${CMAKE_CURRENT_SOURCE_DIR}/scripts/build_python.bat
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
if (NOT EXISTS ${CMAKE_BINARY_DIR}/bin/python/python.exe)
file(COPY ${CMAKE_CURRENT_LIST_DIR}/python DESTINATION ${CMAKE_BINARY_DIR}/bin)
file(COPY ${CMAKE_CURRENT_LIST_DIR}/python/python310.dll DESTINATION ${CMAKE_BINARY_DIR}/bin)
file(COPY ${CMAKE_CURRENT_LIST_DIR}/python/python3.dll DESTINATION ${CMAKE_BINARY_DIR}/bin)
endif()
file(COPY mp_mocap DESTINATION ${CMAKE_BINARY_DIR}/bin/python/Lib/site-packages)
else()
execute_process(COMMAND sh "scripts/build_python_linux.sh" WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
if (NOT EXISTS ${CMAKE_BINARY_DIR}/bin/python/bin/python)
file(COPY ${CMAKE_CURRENT_LIST_DIR}/python DESTINATION ${CMAKE_BINARY_DIR}/bin)
endif()
file(COPY mp_mocap DESTINATION ${CMAKE_BINARY_DIR}/bin/python/lib/python3.10/site-packages)
endif()
message("==========================================================")
message("Compiler")
message(STATUS " - ID \t: ${CMAKE_CXX_COMPILER_ID}")
message(STATUS " - Version \t: ${CMAKE_CXX_COMPILER_VERSION}")
message(STATUS " - Path \t: ${CMAKE_CXX_COMPILER}")
# for external option
option(JSONCPP_WITH_TESTS OFF)
option(GLFW_BUILD_DOCS OFF)
option(ASSIMP_BUILD_ZLIB ON)
option(ASSIMP_BUILD_TESTS OFF)
option(ASSIMP_BUILD_ASSIMP_TOOLS OFF)
if(WIN32)
option(ASSIMP_RAPIDJSON_NO_MEMBER_ITERATOR OFF)
set(ASSIMP_RAPIDJSON_NO_MEMBER_ITERATOR OFF)
endif()
set(ASSIMP_BUILD_ZLIB ON)
set(ASSIMP_BUILD_TESTS OFF)
set(ASSIMP_BUILD_ASSIMP_TOOLS OFF)
# add external libraries
message("GLAD")
add_subdirectory(external/glad/)
message("STB")
add_library(STB_IMAGE "external/stb/stb_image.cpp")
if(WIN32)
message("GLFW")
add_subdirectory(external/glfw/)
message("IMGUI")
add_subdirectory(external/imgui/)
message("ASSIMP")
add_subdirectory(external/assimp/)
else()
add_subdirectory(external/imgui/)
add_subdirectory(external/assimp/)
add_subdirectory(external/glfw/)
endif()
message("hiredis")
add_subdirectory(external/hiredis)
message("jsoncpp")
add_subdirectory(external/jsoncpp)
message("GLM")
add_subdirectory(external/glm/)
message("Python" ${CMAKE_BINARY_DIR}/bin/python/)
set(Python3_ROOT_DIR ${CMAKE_BINARY_DIR}/bin/python)
set(CMAKE_FIND_ROOT_PATH ${CMAKE_BINARY_DIR})
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
find_package(Python3 3.10 EXACT COMPONENTS Interpreter Development REQUIRED)
GET_TARGET_PROPERTY(\_lib Python3::Python IMPORTED_IMPLIB)
MESSAGE(STATUS "Python3::Python ${\_lib}")
GET_TARGET_PROPERTY(\_lib Python3::Python IMPORTED_IMPLIB_DEBUG)
MESSAGE(STATUS "Python3::Python (Debug) ${\_lib}")
GET_TARGET_PROPERTY(\_lib Python3::Python IMPORTED_IMPLIB_RELEASE)
MESSAGE(STATUS "Python3::Python (Release) ${\_lib}")
message(STATUS "Python3 Executable: ${Python3_EXECUTABLE}")
message(STATUS "Python3 Include Dirs: ${Python3_INCLUDE_DIRS}")
message(STATUS "Python3 Library: ${Python3_LIBRARY}")
message("pybind11")
add_subdirectory(external/pybind11)
message(STATUS "Found pybind11 v${pybind11_VERSION}: ${pybind11_INCLUDE_DIRS} ${pybind11_DEFINITIONS} ${pybind11_LIBRARIES}")
message("==========================================================")
add_subdirectory(src)
add_dependencies (imgui glfw)
add_dependencies(STB_IMAGE imgui)
add_dependencies(glcpp assimp)