-
Notifications
You must be signed in to change notification settings - Fork 135
/
CMakeLists.txt
77 lines (63 loc) · 2.2 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
cmake_minimum_required(VERSION 3.11)
project(OpenFBX LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 11)
include(GNUInstallDirs)
include(FetchContent)
FetchContent_Declare(
libdeflate
GIT_REPOSITORY https://github.com/ebiggers/libdeflate.git
GIT_TAG master
)
FetchContent_MakeAvailable(libdeflate)
# Check if libdeflate_static is already defined
if(NOT TARGET libdeflate_static)
add_library(libdeflate_static STATIC IMPORTED)
set_target_properties(libdeflate_static PROPERTIES
IMPORTED_LOCATION "${libdeflate_SOURCE_DIR}/libdeflate.a"
INTERFACE_INCLUDE_DIRECTORIES "${libdeflate_SOURCE_DIR}"
)
endif()
# Check if libdeflate_shared is already defined
if(NOT TARGET libdeflate_shared)
add_library(libdeflate_shared SHARED IMPORTED)
set_target_properties(libdeflate_shared PROPERTIES
IMPORTED_LOCATION "${libdeflate_SOURCE_DIR}/libdeflate.so"
INTERFACE_INCLUDE_DIRECTORIES "${libdeflate_SOURCE_DIR}"
)
endif()
add_library(OpenFBX src/ofbx.cpp)
target_link_libraries(OpenFBX PRIVATE libdeflate_static)
target_include_directories(OpenFBX
PUBLIC
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
PRIVATE
${libdeflate_SOURCE_DIR}
)
target_compile_definitions(OpenFBX PRIVATE _LARGEFILE64_SOURCE)
set_target_properties(OpenFBX PROPERTIES
WINDOWS_EXPORT_ALL_SYMBOLS ON
POSITION_INDEPENDENT_CODE ON)
install(TARGETS OpenFBX EXPORT openfbxTargets
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
INCLUDES DESTINATION include)
include(CMakePackageConfigHelpers)
configure_package_config_file(
openfbxConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/openfbxConfig.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_DATADIR}/openfbx"
)
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/openfbxConfig.cmake"
DESTINATION "${CMAKE_INSTALL_DATADIR}/openfbx"
)
install(
EXPORT openfbxTargets
FILE openfbxTargets.cmake
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/openfbx
)
install(FILES ${CMAKE_SOURCE_DIR}/src/ofbx.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)