forked from floooh/qoiview
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
45 lines (43 loc) · 2.15 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
cmake_minimum_required(VERSION 3.5)
project(qoiview)
set(CMAKE_C_STANDARD 99)
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
add_executable(qoiview WIN32 qoiview.c)
target_link_libraries(qoiview PRIVATE d3d11)
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT qoiview)
else()
add_executable(qoiview qoiview.c)
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
target_compile_options(qoiview PRIVATE -x objective-c)
target_link_libraries(qoiview PRIVATE "-framework QuartzCore" "-framework Cocoa" "-framework MetalKit" "-framework Metal")
elseif (CMAKE_SYSTEM_NAME STREQUAL Linux)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
target_link_libraries(qoiview PRIVATE X11 Xi Xcursor GL dl m)
target_link_libraries(qoiview PRIVATE Threads::Threads)
elseif (CMAKE_SYSTEM_NAME STREQUAL OpenBSD)
target_include_directories(qoiview PRIVATE "/usr/X11R6/include")
target_link_directories(qoiview PRIVATE "/usr/X11R6/lib")
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
target_link_libraries(qoiview PRIVATE X11 Xi Xcursor GL m pthread)
elseif (CMAKE_SYSTEM_NAME STREQUAL Emscripten)
set(CMAKE_EXECUTABLE_SUFFIX ".html")
target_link_options(qoiview PRIVATE --shell-file ../sokol/shell.html)
target_link_options(qoiview PRIVATE -sINITIAL_MEMORY=67108864 -sNO_FILESYSTEM=1 -sASSERTIONS=0 -sMALLOC=emmalloc --closure=1)
endif()
endif()
if (CMAKE_C_COMPILER_ID MATCHES "Clang" AND NOT CMAKE_SYSTEM_NAME STREQUAL Emscripten AND NOT CMAKE_SYSTEM_NAME STREQUAL OpenBSD)
find_program(LLVM_STRIP_EXECUTABLE NAMES llvm-strip PATHS ${LLVM_TOOLS_BINARY_DIR})
if (LLVM_STRIP_EXECUTABLE)
message(STATUS "Found llvm-strip: ${LLVM_STRIP_EXECUTABLE}")
add_custom_command(
TARGET qoiview POST_BUILD
COMMAND ${LLVM_STRIP_EXECUTABLE} $<TARGET_FILE:qoiview>
COMMENT "Stripping symbols from target"
)
else()
message(STATUS "llvm-strip not found. Using dead_strip linker flag")
target_link_options(qoiview PRIVATE LINKER:-dead_strip)
endif()
endif()