Skip to content

Commit e8cf527

Browse files
committed
CMake: Move remaining options together.
Regroup all the other options into the same module. Also tweak some options: - Remove ENABLE_LTO, users should simply set CMAKE_INTERPROCEDURAL_OPTIMIZATION instead. - Make the binary and copyright install directories options instead of forcing them on Windows.
1 parent 1370067 commit e8cf527

File tree

3 files changed

+41
-44
lines changed

3 files changed

+41
-44
lines changed

prboom2/CMakeLists.txt

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,12 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
1818
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
1919
endif()
2020

21-
include(GNUInstallDirs)
22-
2321
if(POLICY CMP0099)
2422
cmake_policy(SET CMP0099 NEW)
2523
else()
2624
message(WARNING "Your version of CMake is very old. This may cause linking issues if your dependencies are not in your compiler's default search paths.")
2725
endif()
2826

29-
option(CMAKE_FIND_PACKAGE_PREFER_CONFIG "Search for package config before using Find modules" ON)
30-
3127
if(VCPKG_TOOLCHAIN)
3228
set(ENV{PKG_CONFIG_PATH} "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/pkgconfig")
3329
endif()
@@ -36,16 +32,11 @@ if(POLICY CMP0069)
3632
cmake_policy(SET CMP0069 NEW)
3733
endif()
3834

39-
include(CheckIPOSupported)
40-
check_ipo_supported(RESULT HAVE_LTO)
41-
42-
include(CMakeDependentOption)
43-
cmake_dependent_option(ENABLE_LTO "Use link-time optimisation" OFF "HAVE_LTO" OFF)
44-
4535
set(PROJECT_TARNAME "dsda-doom")
4636
set(WAD_DATA "dsda-doom.wad")
4737
set(PROJECT_STRING "${PROJECT_NAME} ${PROJECT_VERSION}")
4838

39+
include(DsdaOptions)
4940
include(DsdaTargetFeatures)
5041

5142
include(PkgConfigHelper)
@@ -118,26 +109,6 @@ if(WITH_PORTMIDI)
118109
endif()
119110
endif()
120111

121-
if(WIN32)
122-
set(DEFAULT_WAD_DIR ".")
123-
else()
124-
set(DEFAULT_WAD_DIR "share/games/doom")
125-
endif()
126-
127-
set(DSDAPWADDIR "${DEFAULT_WAD_DIR}" CACHE STRING "Path to install DSDA-Doom internal WAD, relative to CMAKE_INSTALL_PREFIX or absolute.")
128-
set(DOOMWADDIR "${CMAKE_INSTALL_PREFIX}/${DEFAULT_WAD_DIR}" CACHE PATH "Path to look for WAD files.")
129-
130-
if(IS_ABSOLUTE "${DSDAPWADDIR}")
131-
set(DSDA_ABSOLUTE_PWAD_PATH "${DSDAPWADDIR}")
132-
else()
133-
set(DSDA_ABSOLUTE_PWAD_PATH "${CMAKE_INSTALL_PREFIX}/${DSDAPWADDIR}")
134-
endif()
135-
136-
option(SIMPLECHECKS "Enable checks which only impose significant overhead if a posible error is detected" ON)
137-
138-
# Debug options, disabled by default
139-
option(RANGECHECK "Enable internal range checking" OFF)
140-
141112
include(DsdaConfigHeader)
142113

143114
set(DSDA_OUTPUT_PATH ${CMAKE_BINARY_DIR})
@@ -181,11 +152,10 @@ install(FILES
181152
DESTINATION "${DSDAPWADDIR}"
182153
)
183154

184-
if(WIN32)
185-
install(FILES COPYING DESTINATION . RENAME COPYING.txt)
186-
else()
187-
install(FILES COPYING DESTINATION "share/doc/${PROJECT_NAME}")
188-
endif()
155+
install(FILES
156+
"COPYING"
157+
DESTINATION "${DSDA_INSTALL_COPYRIGHT_DIR}"
158+
)
189159

190160
if(WIN32)
191161
set(CPACK_GENERATOR ZIP)

prboom2/cmake/DsdaOptions.cmake

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
include_guard()
2+
3+
if(WIN32)
4+
set(default_bin_dir ".")
5+
set(default_wad_dir ".")
6+
set(default_copyright_dir ".")
7+
else()
8+
include(GNUInstallDirs)
9+
set(default_bin_dir "${CMAKE_INSTALL_BINDIR}")
10+
set(default_wad_dir "${CMAKE_INSTALL_DATAROOTDIR}/games/doom")
11+
set(default_copyright_dir "${CMAKE_INSTALL_DATAROOTDIR}/doc/${PROJECT_NAME}")
12+
endif()
13+
14+
set(DSDAPWADDIR "${default_wad_dir}" CACHE STRING "Path to install DSDA-Doom internal WAD")
15+
set(DOOMWADDIR "${CMAKE_INSTALL_PREFIX}/${default_wad_dir}" CACHE PATH "Path to look for WAD files.")
16+
set(DSDA_INSTALL_COPYRIGHT_DIR "${default_copyright_dir}" CACHE STRING "Destination of the copyright file")
17+
set(DSDA_INSTALL_BINDIR "${default_bin_dir}" CACHE STRING "Destination of the dsda-doom binary")
18+
19+
option(SIMPLECHECKS "Enable checks which only impose significant overhead if a posible error is detected" ON)
20+
option(RANGECHECK "Enable internal range checking" OFF)
21+
22+
option(CMAKE_FIND_PACKAGE_PREFER_CONFIG "Search for package config before using Find modules" ON)
23+
24+
if(IS_ABSOLUTE "${DSDAPWADDIR}")
25+
set(DSDA_ABSOLUTE_PWAD_PATH "${DSDAPWADDIR}")
26+
else()
27+
set(DSDA_ABSOLUTE_PWAD_PATH "${CMAKE_INSTALL_PREFIX}/${DSDAPWADDIR}")
28+
endif()
29+
30+
# Removed options
31+
32+
if(DEFINED CACHE{ENABLE_LTO})
33+
message(AUTHOR_WARNING "ENABLE_LTO has been removed, set CMAKE_INTERPROCEDURAL_OPTIMIZATION instead")
34+
endif()

prboom2/src/CMakeLists.txt

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,6 @@ function(AddGameExecutable TARGET SOURCES)
559559

560560
set_target_properties(${TARGET} PROPERTIES
561561
RUNTIME_OUTPUT_DIRECTORY ${DSDA_OUTPUT_PATH}
562-
INTERPROCEDURAL_OPTIMIZATION ${ENABLE_LTO}
563562
C_STANDARD 99
564563
)
565564

@@ -603,12 +602,6 @@ function(AddGameExecutable TARGET SOURCES)
603602
)
604603
endif()
605604

606-
if(WIN32)
607-
set(DSDA_BINARY_INSTALL_DIR ".")
608-
else()
609-
set(DSDA_BINARY_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}")
610-
endif()
611-
612605
if(CMAKE_VERSION VERSION_GREATER 3.20
613606
AND WIN32
614607
AND NOT VCPKG_TOOLCHAIN
@@ -619,10 +612,10 @@ function(AddGameExecutable TARGET SOURCES)
619612
PRE_EXCLUDE_REGEXES "api-ms-" "ext-ms-"
620613
POST_EXCLUDE_REGEXES ".*system32/.*\\.dll"
621614
DIRECTORIES $<TARGET_FILE_DIR:${TARGET}> $ENV{PATH}
622-
RUNTIME DESTINATION "${DSDA_BINARY_INSTALL_DIR}"
615+
RUNTIME DESTINATION "${DSDA_INSTALL_BINDIR}"
623616
)
624617
else()
625-
install(TARGETS ${TARGET} RUNTIME DESTINATION "${DSDA_BINARY_INSTALL_DIR}")
618+
install(TARGETS ${TARGET} RUNTIME DESTINATION "${DSDA_INSTALL_BINDIR}")
626619
endif()
627620

628621
target_link_libraries(${TARGET} PRIVATE

0 commit comments

Comments
 (0)