From a9365cd34eff61fe5d2ce35939a23ac6e760409d Mon Sep 17 00:00:00 2001 From: Scott Giese Date: Thu, 26 Dec 2019 01:26:44 -0600 Subject: [PATCH] Embedded Resources: Fix for Ninja 1.9 Refactor to break circular references. New custom target generates the resource files. FGFS and Test_Suite targets declare a dependency to the generated files. --- CMakeModules/SetupFGFSEmbeddedResources.cmake | 8 -------- src/EmbeddedResources/CMakeLists.txt | 16 ++++++++++++++++ src/Main/CMakeLists.txt | 5 ++++- test_suite/CMakeLists.txt | 6 +++++- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/CMakeModules/SetupFGFSEmbeddedResources.cmake b/CMakeModules/SetupFGFSEmbeddedResources.cmake index df0c81530..18af97687 100644 --- a/CMakeModules/SetupFGFSEmbeddedResources.cmake +++ b/CMakeModules/SetupFGFSEmbeddedResources.cmake @@ -25,12 +25,4 @@ function(setup_fgfs_embedded_resources) "Either MSVC_3RDPARTY_ROOT or MSVC_3RDPARTY_DIR is empty or unset") endif() endif() - - add_custom_command( - OUTPUT ${CMAKE_BINARY_DIR}/src/EmbeddedResources/FlightGear-resources.cxx - ${CMAKE_BINARY_DIR}/src/EmbeddedResources/FlightGear-resources.hxx - COMMAND fgrcc --root=${CMAKE_SOURCE_DIR} --output-cpp-file=${CMAKE_BINARY_DIR}/src/EmbeddedResources/FlightGear-resources.cxx --init-func-name=initFlightGearEmbeddedResources --output-header-file=${CMAKE_BINARY_DIR}/src/EmbeddedResources/FlightGear-resources.hxx --output-header-identifier=_FG_FLIGHTGEAR_EMBEDDED_RESOURCES ${CMAKE_SOURCE_DIR}/src/EmbeddedResources/FlightGear-resources.xml - DEPENDS - fgrcc ${CMAKE_SOURCE_DIR}/src/EmbeddedResources/FlightGear-resources.xml - ) endfunction() diff --git a/src/EmbeddedResources/CMakeLists.txt b/src/EmbeddedResources/CMakeLists.txt index 662623a0e..d72d9629b 100644 --- a/src/EmbeddedResources/CMakeLists.txt +++ b/src/EmbeddedResources/CMakeLists.txt @@ -1,2 +1,18 @@ add_executable(fgrcc fgrcc.cxx fgrcc.hxx) target_link_libraries(fgrcc SimGearCore ${PLATFORM_LIBS}) + +add_custom_target( + embeddedresources + COMMAND + fgrcc --root=${CMAKE_SOURCE_DIR} + --output-cpp-file=${CMAKE_BINARY_DIR}/src/EmbeddedResources/FlightGear-resources.cxx + --init-func-name=initFlightGearEmbeddedResources + --output-header-file=${CMAKE_BINARY_DIR}/src/EmbeddedResources/FlightGear-resources.hxx + --output-header-identifier=_FG_FLIGHTGEAR_EMBEDDED_RESOURCES + ${CMAKE_SOURCE_DIR}/src/EmbeddedResources/FlightGear-resources.xml + BYPRODUCTS + ${CMAKE_BINARY_DIR}/src/EmbeddedResources/FlightGear-resources.cxx + ${CMAKE_BINARY_DIR}/src/EmbeddedResources/FlightGear-resources.hxx + DEPENDS + fgrcc ${CMAKE_SOURCE_DIR}/src/EmbeddedResources/FlightGear-resources.xml +) diff --git a/src/Main/CMakeLists.txt b/src/Main/CMakeLists.txt index 61602970a..391446f73 100644 --- a/src/Main/CMakeLists.txt +++ b/src/Main/CMakeLists.txt @@ -73,6 +73,9 @@ get_property(FG_HEADERS GLOBAL PROPERTY FG_HEADERS) get_property(EMBEDDED_RESOURCE_SOURCES GLOBAL PROPERTY EMBEDDED_RESOURCE_SOURCES) get_property(EMBEDDED_RESOURCE_HEADERS GLOBAL PROPERTY EMBEDDED_RESOURCE_HEADERS) +set_source_files_properties(${EMBEDDED_RESOURCE_SOURCES} PROPERTIES GENERATED TRUE) +set_source_files_properties(${EMBEDDED_RESOURCE_HEADERS} PROPERTIES GENERATED TRUE) + # important we pass WIN32 here so the console is optional. Other # platforms ignore this option. If a console is needed we allocate # it manually via AllocConsole() @@ -87,7 +90,7 @@ add_executable(fgfs ${EMBEDDED_RESOURCE_HEADERS} ) -add_dependencies(fgfs buildId) +add_dependencies(fgfs buildId embeddedresources) # explicitly disable automoc for main fgfs target set_property(TARGET fgfs PROPERTY AUTOMOC OFF) diff --git a/test_suite/CMakeLists.txt b/test_suite/CMakeLists.txt index 859820812..89ce2d831 100644 --- a/test_suite/CMakeLists.txt +++ b/test_suite/CMakeLists.txt @@ -116,6 +116,9 @@ get_property(FG_HEADERS GLOBAL PROPERTY FG_HEADERS) get_property(EMBEDDED_RESOURCE_SOURCES GLOBAL PROPERTY EMBEDDED_RESOURCE_SOURCES) get_property(EMBEDDED_RESOURCE_HEADERS GLOBAL PROPERTY EMBEDDED_RESOURCE_HEADERS) +set_source_files_properties(${EMBEDDED_RESOURCE_SOURCES} PROPERTIES GENERATED TRUE) +set_source_files_properties(${EMBEDDED_RESOURCE_HEADERS} PROPERTIES GENERATED TRUE) + # Set up the separate executable for running the test suite. add_executable(fgfs_test_suite ${FG_SOURCES} @@ -125,7 +128,8 @@ add_executable(fgfs_test_suite ${TESTSUITE_SOURCES} ${TESTSUITE_HEADERS} ) -add_dependencies(fgfs_test_suite buildId) + +add_dependencies(fgfs_test_suite buildId embeddedresources) set_target_properties(fgfs_test_suite PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${TESTSUITE_OUTPUT_DIR}"