1
1
# CMake Project for SDL_gpu_shadercross - Simple DirectMedia Layer Shader Cross Compiler
2
2
# Written by @thatcosmonaut
3
- cmake_minimum_required (VERSION 3.8 )
3
+ cmake_minimum_required (VERSION 3.22 )
4
4
5
5
# Version
6
6
set (MAJOR_VERSION "1" )
@@ -10,13 +10,17 @@ set(SDL_REQUIRED_VERSION "3.1.3")
10
10
11
11
project (SDL_gpu_shadercross LANGUAGES C VERSION "${MAJOR_VERSION} .${MINOR_VERSION} .${MICRO_VERSION} " )
12
12
13
+ include ("${CMAKE_CURRENT_LIST_DIR} /cmake/PrivateSdlFunctions.cmake" )
14
+ include (CMakeDependentOption )
15
+
16
+ find_package (SDL3 REQUIRED COMPONENTS SDL3-shared )
17
+
13
18
# Options
14
19
option (BUILD_STATIC "Build static library" ON )
15
20
option (BUILD_CLI "Build command line executable" ON )
16
21
option (ENABLE_WERROR "Enable Werror" OFF )
17
22
option (ENABLE_INSTALL "Enable installation" OFF )
18
-
19
- include ("${CMAKE_CURRENT_LIST_DIR} /cmake/PrivateSdlFunctions.cmake" )
23
+ cmake_dependent_option (BUILD_CLI_STATIC "Link CLI with static libraries" OFF "BUILD_CLI;BUILD_STATIC;TARGET SDL3::SDL3-static" OFF )
20
24
21
25
sdl_calculate_derived_version_variables (${MAJOR_VERSION} ${MINOR_VERSION} ${MICRO_VERSION} )
22
26
@@ -35,13 +39,11 @@ set(SOURCE_FILES
35
39
# Public Headers
36
40
include /SDL_gpu_shadercross.h
37
41
# Source Files
38
- src/SDL_gpu_shadercross.c
39
- src/spirv_cross_c.h
40
- src/spirv.h
42
+ src/SDL_gpu_shadercross.c
43
+ src/spirv_cross_c.h
44
+ src/spirv.h
41
45
)
42
46
43
- find_package (SDL3 REQUIRED COMPONENTS SDL3-shared )
44
-
45
47
add_library (SDL_gpu_shadercross-shared SHARED ${SOURCE_FILES} )
46
48
add_library (SDL_gpu_shadercross::SDL_gpu_shadercross ALIAS SDL_gpu_shadercross-shared )
47
49
@@ -71,13 +73,13 @@ set_target_properties(SDL_gpu_shadercross-shared PROPERTIES OUTPUT_NAME "SDL_gpu
71
73
)
72
74
73
75
target_link_libraries (SDL_gpu_shadercross-shared PRIVATE
74
- SDL3::SDL3-shared
76
+ SDL3::SDL3-shared
75
77
)
76
78
77
79
if (BUILD_STATIC )
78
80
find_package (SDL3 REQUIRED COMPONENTS Headers )
79
81
80
- add_library (SDL_gpu_shadercross-static STATIC ${SOURCE_FILES} )
82
+ add_library (SDL_gpu_shadercross-static STATIC ${SOURCE_FILES} )
81
83
add_library (SDL_gpu_shadercross::SDL_gpu_shadercross-static ALIAS SDL_gpu_shadercross-static )
82
84
sdl_add_warning_options (SDL_gpu_shadercross-static WARNING_AS_ERROR ${ENABLE_WERROR} )
83
85
target_compile_features (SDL_gpu_shadercross-static PRIVATE c_std_99 )
@@ -86,12 +88,12 @@ if(BUILD_STATIC)
86
88
set_property (TARGET SDL_gpu_shadercross-static PROPERTY OUTPUT_NAME "SDL_gpu_shadercross" )
87
89
endif ()
88
90
89
- # SDL_gpu_shadercross folders as includes, for other targets to consume
90
- target_include_directories (SDL_gpu_shadercross-static PUBLIC $< BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /include> )
91
+ # SDL_gpu_shadercross folders as includes, for other targets to consume
92
+ target_include_directories (SDL_gpu_shadercross-static PUBLIC $< BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /include> )
91
93
92
- target_link_libraries (SDL_gpu_shadercross-static PUBLIC
93
- SDL3::Headers
94
- )
94
+ target_link_libraries (SDL_gpu_shadercross-static PUBLIC
95
+ SDL3::Headers
96
+ )
95
97
endif ()
96
98
97
99
if (NOT TARGET SDL_gpu_shadercross::SDL_gpu_shadercross )
@@ -103,10 +105,15 @@ if(NOT TARGET SDL_gpu_shadercross::SDL_gpu_shadercross)
103
105
endif ()
104
106
105
107
if (BUILD_CLI )
106
- add_executable (shadercross src/cli.c )
108
+ add_executable (shadercross src/cli.c )
107
109
108
- target_link_libraries (shadercross PRIVATE SDL_gpu_shadercross::SDL_gpu_shadercross )
109
- target_link_libraries (shadercross PRIVATE SDL3::SDL3 )
110
+ if (BUILD_CLI_STATIC )
111
+ target_link_libraries (shadercross PRIVATE SDL_gpu_shadercross::SDL_gpu_shadercross-static )
112
+ target_link_libraries (shadercross PRIVATE SDL3::SDL3-static )
113
+ else ()
114
+ target_link_libraries (shadercross PRIVATE SDL_gpu_shadercross::SDL_gpu_shadercross )
115
+ target_link_libraries (shadercross PRIVATE SDL3::SDL3 )
116
+ endif ()
110
117
endif ()
111
118
112
119
if (ENABLE_INSTALL )
@@ -186,5 +193,4 @@ if(ENABLE_INSTALL)
186
193
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR} /licenses/${PROJECT_NAME} "
187
194
COMPONENT library
188
195
)
189
-
190
196
endif ()
0 commit comments