-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
154 lines (133 loc) · 5.09 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
cmake_minimum_required(VERSION 3.30)
project(PlonsLibrary
VERSION 1.0.0.0
DESCRIPTION "Plons Library is a collection of utils for Anstro Pleuton's programs."
HOMEPAGE_URL "https://anstropleuton.github.io/plons_library/"
LANGUAGES CXX
)
option(BUILD_SHARED_LIBS "Build Plons Library as shared library" OFF)
option(BUILD_TESTS "Build Plons Library tests" OFF)
option(BUILD_EXAMPLES "Build Plons Library usage examples" OFF)
if(NOT DEFINED PLONS_LIBRARY_PHYSX_PATH)
set(PLONS_LIBRARY_PHYSX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/deps/PhysX")
endif()
if(NOT DEFINED PLONS_LIBRARY_BGFX_PATH)
set(PLONS_LIBRARY_BGFX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/deps/bgfx.cmake")
endif()
if(NOT DEFINED PLONS_LIBRARY_GLFW_PATH)
set(PLONS_LIBRARY_GLFW_PATH "${CMAKE_CURRENT_SOURCE_DIR}/deps/glfw")
endif()
if(NOT DEFINED PLONS_LIBRARY_GLM_PATH)
set(PLONS_LIBRARY_GLM_PATH "${CMAKE_CURRENT_SOURCE_DIR}/deps/glm")
endif()
if(NOT DEFINED PLONS_LIBRARY_ALCE_LIBRARY_PATH)
set(PLONS_LIBRARY_ALCE_LIBRARY_PATH "${CMAKE_CURRENT_SOURCE_DIR}/deps/alce_library")
endif()
if(NOT DEFINED PLONS_LIBRARY_PLATFORM)
if(WIN32)
set(PLONS_LIBRARY_PLATFORM "vc17win64") # You can directly set it to vc16win64 if you are using Visual Studio 2019
elseif(UNIX)
if(ARM)
set(PLONS_LIBRARY_PLATFORM "linux-aarch64")
else()
set(PLONS_LIBRARY_PLATFORM "linux")
endif()
endif()
endif()
set(PLONS_LIBRARY_IS_GCC_LIKE_CXX "$<COMPILE_LANG_AND_ID:CXX,ARMClang,AppleClang,Clang,GNU,LCC>")
set(PLONS_LIBRARY_IS_MSVC_CXX "$<COMPILE_LANG_AND_ID:CXX,MSVC>")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/include/plons_library_config.hpp.in" plons_library_config.hpp)
set(PLONS_LIBRARY_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/src/detronade.cpp"
)
set(PLONS_LIBRARY_INCLUDES_DIRECTORIES
"${CMAKE_CURRENT_SOURCE_DIR}/include"
"${CMAKE_CURRENT_BINARY_DIR}"
)
add_library(plons_library ${PLONS_LIBRARY_SOURCES})
target_include_directories(plons_library PUBLIC ${PLONS_LIBRARY_INCLUDES_DIRECTORIES})
target_compile_features(plons_library PUBLIC cxx_std_23)
# Add PhysX
# Use their own outdated piece of shit to get the bin path
cmake_policy(PUSH)
cmake_policy(SET CMP0153 OLD)
include("${PLONS_LIBRARY_PHYSX_PATH}/physx/source/compiler/cmake/modules/GetCompilerAndPlatform.cmake")
GetPlatformBinName(PLATFORM_BIN_NAME "64")
cmake_policy(POP)
target_include_directories(plons_library PUBLIC "${PLONS_LIBRARY_PHYSX_PATH}/physx/include")
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_definitions(plons_library PUBLIC _DEBUG)
target_link_directories(plons_library PUBLIC "${PLONS_LIBRARY_PHYSX_PATH}/physx/bin/${PLATFORM_BIN_NAME}/debug")
else()
target_compile_definitions(plons_library PUBLIC NDEBUG)
target_link_directories(plons_library PUBLIC "${PLONS_LIBRARY_PHYSX_PATH}/physx/bin/${PLATFORM_BIN_NAME}/release")
endif()
if(PLONS_LIBRARY_PLATFORM STREQUAL "vc16win64" OR PLONS_LIBRARY_PLATFORM STREQUAL "vc17win64")
target_link_libraries(plons_library PUBLIC
freeglut
PhysXCommon_64
PhysXCooking_64
PhysXDevice64
PhysXFoundation_64
PhysXGpu_64
PhysX_64
PVDRuntime_64
)
elseif(PLONS_LIBRARY_PLATFORM STREQUAL "linux" OR PLONS_LIBRARY_PLATFORM STREQUAL "linux-aarch64") # TODO: Test with linux-aarch64 (I don't own one)
target_link_libraries(plons_library PUBLIC
#PhysXCharacterKinematic_static_64
#PhysXCommon_static_64
#PhysXCooking_static_64
#PhysXExtensions_static_64
#PhysXFoundation_static_64
#PhysXGpu_64
#PhysXPvdSDK_static_64
#PhysX_static_64
#PhysXVehicle2_static_64
#PhysXVehicle_static_64
#PVDRuntime_64
)
endif()
# Add BGFX
# Just look how simple this is compared to pHySx
find_package(bgfx QUIET)
if(NOT bgfx_FOUND)
message("bgfx not found, adding subdirectory ${PLONS_LIBRARY_BGFX_PATH}")
add_subdirectory(${PLONS_LIBRARY_BGFX_PATH})
else()
message("bgfx found in system, using it instead")
endif()
target_link_libraries(plons_library PUBLIC bgfx bimg bx)
# Add GLFW
find_package(glfw3 QUIET)
if(NOT glfw3_FOUND)
message("glfw3 not found, adding subdirectory ${PLONS_LIBRARY_GLFW_PATH}")
add_subdirectory(${PLONS_LIBRARY_GLFW_PATH})
else()
message("glfw3 found in system, using it instead")
endif()
target_link_libraries(plons_library PUBLIC glfw)
# Add GLM
find_package(glm QUIET)
if(NOT glm_FOUND)
message("glm not found, adding subdirectory ${PLONS_LIBRARY_GLM_PATH}")
add_subdirectory(${PLONS_LIBRARY_GLM_PATH})
else()
message("glm found in system, using it instead")
endif()
target_link_libraries(plons_library PUBLIC glm)
# Add my own library, Alce
find_package(alce_library QUIET)
if(NOT alce_library_FOUND)
message("alce_library not found, adding subdirectory ${PLONS_LIBRARY_ALCE_LIBRARY_PATH}")
add_subdirectory(${PLONS_LIBRARY_ALCE_LIBRARY_PATH})
else()
message("alce_library found in system, using it instead")
endif()
target_link_libraries(plons_library PUBLIC alce_library)
if(BUILD_TESTS)
add_subdirectory(tests)
endif()
if(BUILD_EXAMPLES)
add_subdirectory(examples)
endif()