File: CMakeLists.txt

package info (click to toggle)
libtcod 1.24.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,728 kB
  • sloc: ansic: 46,186; cpp: 13,523; python: 4,814; makefile: 44; sh: 25
file content (156 lines) | stat: -rw-r--r-- 4,575 bytes parent folder | download
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
cmake_minimum_required (VERSION 3.13...3.21)

project (libtcod_samples C CXX)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake OPTIONAL RESULT_VARIABLE CONAN_FILE)
if(CONAN_FILE)
    conan_basic_setup(TARGETS)
    set(LINK_TCOD CONAN_PKG::libtcod)
    set(SDL2MAIN)
else()
    find_package(SDL2 CONFIG REQUIRED)
    set(LINK_TCOD libtcod::libtcod)
    set(SDL2MAIN SDL2::SDL2main)
endif()

# This and KEEP_RPATHS is required to handle RPATH's on MacOS.
if (APPLE)
    set(CMAKE_INSTALL_RPATH "@executable_path")
else()
    set(CMAKE_INSTALL_RPATH "$ORIGIN")
endif()
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)

add_custom_target(copy_data_dir
    COMMENT "Copy project data directory to the runtime folder."
    COMMAND cmake -E copy_directory
        ${CMAKE_SOURCE_DIR}/../data
        ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/data
)
add_custom_target(copy_font
    COMMENT "Copy terminal.png to the runtime folder."
    COMMAND cmake -E copy_if_different
        ${CMAKE_SOURCE_DIR}/../terminal.png
        ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/terminal.png
)

# Enforce UTF-8 encoding on MSVC.
add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")

# Enable extra warnings for all samples.
if(MSVC)
    add_compile_options("/W4")
else()
    add_compile_options("-Wall" "-Wextra")
endif()

add_executable(samples_c samples_c.c)
target_link_libraries(samples_c ${LINK_TCOD} ${SDL2MAIN})
if (CONAN_FILE)
    add_dependencies(samples_c copy_data_dir)
endif()
# Suppress MSVC warnings for POSIX C functions such as strdup.  This is only for the C samples.
target_compile_definitions(samples_c PRIVATE "$<$<C_COMPILER_ID:MSVC>:_CRT_NONSTDC_NO_DEPRECATE>")

add_executable(samples_cpp samples_cpp.cpp)
target_link_libraries(samples_cpp ${LINK_TCOD} ${SDL2MAIN})
if (CONAN_FILE)
    add_dependencies(samples_cpp copy_data_dir)
endif()

add_executable(frost frost/frost.cpp)
target_link_libraries(frost ${LINK_TCOD} ${SDL2MAIN})
if (CONAN_FILE)
    add_dependencies(frost copy_font)
endif()

add_executable(hmtool
    hmtool/hmtool.cpp hmtool/operation.cpp hmtool/operation.hpp
)
target_link_libraries(hmtool ${LINK_TCOD} ${SDL2MAIN})
if (CONAN_FILE)
    add_dependencies(hmtool copy_font)
endif()

add_executable(navier navier/main.cpp)
target_link_libraries(navier ${LINK_TCOD} ${SDL2MAIN})
if (CONAN_FILE)
    add_dependencies(navier copy_font)
endif()

add_executable(rad
    rad/main.cpp
    rad/bsp_helper.cpp
    rad/bsp_helper.hpp
    rad/rad_shader.cpp
    rad/rad_shader.hpp
    rad/rad_shader_photon.cpp
    rad/rad_shader_standard.cpp
)
target_link_libraries(rad ${LINK_TCOD} ${SDL2MAIN})
if (CONAN_FILE)
    add_dependencies(rad copy_font)
endif()

add_executable(ripples
    ripples/main.cpp
    ripples/main.hpp
    ripples/util_ripples.cpp
    ripples/util_ripples.hpp
)
target_link_libraries(ripples ${LINK_TCOD} ${SDL2MAIN})
if (CONAN_FILE)
    add_dependencies(ripples copy_font)
endif()

add_executable(weather
    weather/main.cpp
    weather/main.hpp
    weather/util_weather.cpp
    weather/util_weather.hpp
)
target_link_libraries(weather ${LINK_TCOD} ${SDL2MAIN})
if (CONAN_FILE)
    add_dependencies(weather copy_font)
endif()

add_executable(worldgen
    worldgen/main.cpp
    worldgen/main.hpp
    worldgen/util_worldgen.cpp
    worldgen/util_worldgen.hpp
)
target_link_libraries(worldgen ${LINK_TCOD} ${SDL2MAIN})
if (CONAN_FILE)
    add_dependencies(worldgen copy_font)
endif()

if (EMSCRIPTEN)
    # Attach data to Emscripten builds.
    foreach(project_it samples_c samples_cpp)
        target_link_options(
            ${project_it} PRIVATE
            "SHELL:--preload-file ${CMAKE_CURRENT_SOURCE_DIR}/../data/fonts/dejavu10x10_gs_tc.png@/data/fonts/"
            "SHELL:--preload-file ${CMAKE_CURRENT_SOURCE_DIR}/../data/img@/data/img/"
            "SHELL:--preload-file ${CMAKE_CURRENT_SOURCE_DIR}/../data/namegen@/data/namegen/"
        )
    endforeach()
    target_link_options(
        frost PRIVATE
        "SHELL:--preload-file ${CMAKE_CURRENT_SOURCE_DIR}/../data/fonts/terminal8x8_gs_tc.png@/data/fonts/"
    )
    foreach(project_it hmtool navier rad weather worldgen)
        target_link_options(
            ${project_it} PRIVATE
            "SHELL:--preload-file ${CMAKE_CURRENT_SOURCE_DIR}/../data@/data/"
        )
    endforeach()

    # Set output to html to generate preview pages, otherwise you'll have to make your own html.
    set_target_properties(
        samples_c samples_cpp frost hmtool navier rad weather worldgen
        PROPERTIES
            SUFFIX ".html"
    )
endif()