-
Notifications
You must be signed in to change notification settings - Fork 9
/
CMakeLists.txt
51 lines (40 loc) · 1.56 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
cmake_minimum_required(VERSION 3.21)
project(c-octo VERSION 1.2 LANGUAGES C)
if(WIN32)
set(INSTALLDIR .)
else()
set(INSTALLDIR bin)
endif()
add_compile_definitions(VERSION="${PROJECT_VERSION}")
if(UNIX AND NOT APPLE)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED)
add_compile_options(-lm)
endif()
if(MSVC)
add_compile_options(/Wall) # MSVC uses /Wall as the highest warning level, includes /W4 and more.
#add_compile_options(/Wall /WX) # MSVC reports multiple errors that presumably other platforms don't, /WX is the equivalent to -Werror but means builds cannot complete under MSVC with an equivalent to the provided Makefile
else()
add_compile_options(-Wall -Werror -Wextra)
endif()
if(APPLE)
add_compile_options(-Wpedantic)
elseif(NOT MSVC)
add_compile_options(-Wno-format-truncation)
endif()
add_executable(octo-cli src/octo_cli.c)
find_package(SDL2)
if(SDL2_FOUND)
add_executable(octo-run src/octo_run.c)
target_link_libraries(octo-run PRIVATE SDL2::SDL2 SDL2::SDL2main)
add_executable(octo-de src/octo_de.c)
target_link_libraries(octo-de PRIVATE SDL2::SDL2 SDL2::SDL2main)
install(TARGETS octo-cli octo-run octo-de DESTINATION ${INSTALLDIR})
if(MSVC)
# default is to dynamically link SDL2, MSVC copies the file to the build directory but we need to copy it on to the install directory manually.
install(FILES ${CMAKE_BINARY_DIR}/SDL2$<$<CONFIG:Debug>:d>.dll DESTINATION ${INSTALLDIR})
endif()
else()
message("SDL2 could not be found, only Octo-cli will be built.")
install(TARGETS octo-cli DESTINATION ${INSTALLDIR})
endif()