summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-06-05 11:46:54 +0200
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-06-05 11:46:57 +0200
commita5547c7d62a41b784d88e5eabe9355921384b03a (patch)
treecedbc977d92bdb45cbf152a52ce2b82260604a90
parent92c41206656d37e8686e30524c3cd376a7e1a216 (diff)
downloadtmwa-a5547c7d62a41b784d88e5eabe9355921384b03a.tar.gz
tmwa-a5547c7d62a41b784d88e5eabe9355921384b03a.tar.bz2
tmwa-a5547c7d62a41b784d88e5eabe9355921384b03a.tar.xz
tmwa-a5547c7d62a41b784d88e5eabe9355921384b03a.zip
CMake: Make the build work the first time
Use execute_process instead of add_custom_target to make sure the generated files are found on the first configure run. Set CMAKE_CONFIGURE_DEPENDS so that touching the script generating files will automatically trigger a re-configre, which will re-run the make process.
-rw-r--r--CMakeLists.txt31
1 files changed, 14 insertions, 17 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 51e3b6e..11c58d0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -35,6 +35,20 @@ set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
+# Some sources and includes are generated, such as the protocol headers.
+# We defer to generate.make for these rules.
+# Note that these are raw Makefile rules, not CMake rules, so a simple
+# add_custom_command() won't work.
+execute_process(COMMAND make -f ${CMAKE_SOURCE_DIR}/generate.mk
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+
+# The generate target must be re-run when the scripts change
+set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
+ "${PROJECT_SOURCE_DIR}/generate.mk"
+ "${PROJECT_SOURCE_DIR}/tools/config.py"
+ "${PROJECT_SOURCE_DIR}/tools/protocol.py"
+)
+
# Search through the tree for sources
# For each subfolder in src, add all .cpp files to a subfolder's SOURCES
# variable.
@@ -152,22 +166,5 @@ target_link_libraries(tmwa-admin tmwa-shared)
#add_executable(tmwa-test ${strtest_SOURCES})
#target_link_libraries(tmwa-test tmwa-shared)
-# Some sources and includes are generated, such as the protocol headers.
-# We defer to generate.make for these rules.
-# Note that these are raw Makefile rules, not CMake rules, so a simple
-# add_custom_command() won't work.
-add_custom_target(generate
- COMMAND make -f ${CMAKE_SOURCE_DIR}/generate.mk
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
- COMMENT "Generating sources and includes"
-)
-
# Call make -f ${CMAKE_SOURCE_DIR}/generate.mk clean to clean up the generated
# files. We want this to be run every time we call make clean.
-
-
-# The generate target must be run before building the binaries
-add_dependencies(tmwa-login generate)
-add_dependencies(tmwa-char generate)
-add_dependencies(tmwa-map generate)
-add_dependencies(tmwa-admin generate)