-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
132 lines (119 loc) · 4.52 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
cmake_minimum_required(VERSION 3.10)
project(Texas)
# --------------------------
# Create Texas CMake options
# --------------------------
# START
option(TEXAS_ENABLE_KTX_READ "Enables loading KTX files" ON)
option(TEXAS_ENABLE_KTX_SAVE "Enables saving KTX files" ON)
option(TEXAS_ENABLE_PNG_READ "Enables loading PNG files" ON)
option(TEXAS_ENABLE_DYNAMIC_ALLOCATIONS "Enables new loading paths that use dynamic allocations." ON)
# Mainly for Texas development #
option(TEXAS_BUILD_TESTS "Build test executables." OFF)
#
# END
#
# --------------------
# Create CMake library
# --------------------
# START
# Link .cpp files
set(TEXAS_SRC_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/src/KTX.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/FileInfo.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/PNG.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/PrivateAccessor.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/Texas.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/Texture.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/TextureInfo.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/Tools.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/GLTools.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/VkTools.cpp")
add_library(Texas STATIC ${TEXAS_SRC_FILES})
set_target_properties(Texas PROPERTIES CXX_STANDARD 17)
#
# END
#
# ----------------------
# Link include directory
# ----------------------
# START
set(TEXAS_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
target_include_directories(Texas PUBLIC ${TEXAS_INCLUDE_DIR})
target_include_directories(
Texas
PUBLIC
$<BUILD_INTERFACE:${TEXAS_INCLUDE_DIR}>
$<INSTALL_INTERFACE:include>
)
#
# END
#
# --------------------------
# Handle Texas CMake options
# --------------------------
# START
# Check that atleast one file format has been enabled
if(NOT(
TEXAS_ENABLE_KTX_READ OR
TEXAS_ENABLE_PNG_READ
))
message(FATAL_ERROR "FATAL ERROR: To use Texas you must enable atleast one file-format.")
endif()
if (TEXAS_ENABLE_KTX_READ)
target_compile_definitions(Texas PUBLIC TEXAS_ENABLE_KTX_READ)
target_sources(Texas PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src/KTX_Read.cpp")
endif()
if (TEXAS_ENABLE_KTX_SAVE)
target_compile_definitions(Texas PUBLIC TEXAS_ENABLE_KTX_SAVE)
target_include_directories(Texas PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/optional-includes/KTX_Save")
target_sources(Texas PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src/KTX_Save.cpp")
endif()
if (TEXAS_ENABLE_PNG_READ)
target_compile_definitions(Texas PUBLIC TEXAS_ENABLE_PNG_READ)
target_sources(Texas PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src/PNG_Read.cpp")
set(TEXAS_LINK_ZLIB 1)
endif()
if(TEXAS_ENABLE_DYNAMIC_ALLOCATIONS)
target_compile_definitions(Texas PUBLIC TEXAS_ENABLE_DYNAMIC_ALLOCATIONS)
endif()
if(${TEXAS_LINK_ZLIB})
set(TEXAS_ZLIB_SRC_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/src/zlib/adler32.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/zlib/crc32.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/zlib/deflate.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/zlib/gzclose.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/zlib/gzlib.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/zlib/gzread.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/zlib/gzwrite.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/zlib/infback.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/zlib/inffast.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/zlib/inflate.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/zlib/inftrees.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/zlib/trees.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/zlib/uncompr.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/zlib/zutil.c")
add_library(zlib STATIC ${TEXAS_ZLIB_SRC_FILES})
if(MSVC)
target_compile_definitions(zlib PRIVATE _CRT_SECURE_NO_WARNINGS)
target_compile_options(zlib PRIVATE /wd4996 /wd4267 /wd6297 /wd26451)
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
target_compile_options(zlib PRIVATE -Wno-everything)
endif()
target_link_libraries(Texas PRIVATE zlib)
endif()
#
# END
#
# --------------------------
# Build Texas tests
# --------------------------
# START
if (TEXAS_BUILD_TESTS)
add_executable(compiletest "${CMAKE_CURRENT_SOURCE_DIR}/tests/compiletest.cpp")
set_target_properties(compiletest PROPERTIES CXX_STANDARD 17)
target_link_libraries(compiletest PRIVATE Texas)
endif()
#
# END
#