From 7ca59e590db851466e4cd82fb28ec226e1a20ebd Mon Sep 17 00:00:00 2001 From: Sam V Date: Tue, 16 Jan 2024 20:46:30 +0100 Subject: [PATCH] Move CMake executable definition to root CMakeLists.txt, move cpp.hint --- CMakeLists.txt | 98 +++++++++++++++++++++++++++++++++++++++- src/cpp.hint => cpp.hint | 0 src/CMakeLists.txt | 1 - src/hlam/CMakeLists.txt | 91 ------------------------------------- 4 files changed, 97 insertions(+), 93 deletions(-) rename src/cpp.hint => cpp.hint (100%) delete mode 100644 src/CMakeLists.txt delete mode 100644 src/hlam/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a5eb82d..41278a05 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,4 +68,100 @@ find_package(spdlog CONFIG REQUIRED) find_package(OpenAL CONFIG REQUIRED) find_package(libnyquist CONFIG REQUIRED) -add_subdirectory(src) +# TODO: need to move everything from src/hlam to src once WIP stuff is done + +if (MSVC) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/hlam/version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/version_generated.rc @ONLY) +endif() + +add_executable(HLAM WIN32) + +add_dependencies(HLAM ProjectInfo) + +target_compile_features(HLAM + PRIVATE + cxx_std_20) + +target_include_directories(HLAM + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/src/hlam + ${CMAKE_BINARY_DIR}) + +target_compile_definitions(HLAM + PRIVATE + QT_MESSAGELOGCONTEXT + $<$: + UNICODE + _UNICODE + _CRT_SECURE_NO_WARNINGS + _SCL_SECURE_NO_WARNINGS> + $<$: + FILE_OFFSET_BITS=64>) + +target_link_libraries(HLAM + PRIVATE + Qt5::Widgets + Qt5::Network + fmt::fmt + spdlog::spdlog_header_only + OpenAL::OpenAL + glm::glm + ${CMAKE_DL_LIBS} + libnyquist) + +target_compile_options(HLAM + PRIVATE + $<$:/MP /fp:strict> + $<$:-fPIC>) + +target_link_options(HLAM + PRIVATE + $<$:-Wl,--exclude-libs,ALL>) + +target_sources(HLAM + PRIVATE + src/hlam/Main.cpp + src/hlam/resources.qrc) + +if (MSVC) + target_sources(HLAM PRIVATE src/hlam/hlam.rc src/hlam/version.rc) +endif() + +add_subdirectory(src/hlam/application) +add_subdirectory(src/hlam/entity) +add_subdirectory(src/hlam/filesystem) +add_subdirectory(src/hlam/formats) +add_subdirectory(src/hlam/graphics) +add_subdirectory(src/hlam/plugins) +add_subdirectory(src/hlam/qt) +add_subdirectory(src/hlam/settings) +add_subdirectory(src/hlam/soundsystem) +add_subdirectory(src/hlam/ui) +add_subdirectory(src/hlam/utility) + +#Create filters +get_target_property(SOURCE_FILES HLAM SOURCES) +source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/src/hlam FILES ${SOURCE_FILES}) + +# Add this after source_group to avoid errors with root paths +target_sources(HLAM PRIVATE ${CMAKE_BINARY_DIR}/ProjectInfo.hpp) + +# Copy runtime dependencies automatically for dev builds. +add_custom_command(TARGET HLAM POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ + COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ + COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ + COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ + COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ +) + +# Copy plugins so the program can run +copy_qt_dependencies(HLAM Qt5Core_PLUGINS) +copy_qt_dependencies(HLAM Qt5Gui_PLUGINS) +copy_qt_dependencies(HLAM Qt5Widgets_PLUGINS) +copy_qt_dependencies(HLAM Qt5Network_PLUGINS) + +set_property(DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT HLAM) + +install(TARGETS HLAM + RUNTIME DESTINATION .) diff --git a/src/cpp.hint b/cpp.hint similarity index 100% rename from src/cpp.hint rename to cpp.hint diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt deleted file mode 100644 index 8df9be97..00000000 --- a/src/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_subdirectory(hlam) diff --git a/src/hlam/CMakeLists.txt b/src/hlam/CMakeLists.txt deleted file mode 100644 index 4a10a240..00000000 --- a/src/hlam/CMakeLists.txt +++ /dev/null @@ -1,91 +0,0 @@ -if (MSVC) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/version_generated.rc @ONLY) -endif() - -add_executable(HLAM WIN32) - -add_dependencies(HLAM ProjectInfo) - -target_compile_features(HLAM - PRIVATE - cxx_std_20) - -target_include_directories(HLAM - PRIVATE - ${CMAKE_BINARY_DIR}) - -target_compile_definitions(HLAM - PRIVATE - QT_MESSAGELOGCONTEXT - $<$: - UNICODE - _UNICODE - _CRT_SECURE_NO_WARNINGS - _SCL_SECURE_NO_WARNINGS> - $<$: - FILE_OFFSET_BITS=64>) - -target_link_libraries(HLAM - PRIVATE - Qt5::Widgets - Qt5::Network - fmt::fmt - spdlog::spdlog_header_only - OpenAL::OpenAL - glm::glm - ${CMAKE_DL_LIBS} - libnyquist) - -target_compile_options(HLAM - PRIVATE - $<$:/MP /fp:strict> - $<$:-fPIC>) - -target_link_options(HLAM - PRIVATE - $<$:-Wl,--exclude-libs,ALL>) - -target_sources(HLAM - PRIVATE - $<$:hlam.rc version.rc> - Main.cpp - resources.qrc) - -add_subdirectory(application) -add_subdirectory(entity) -add_subdirectory(filesystem) -add_subdirectory(formats) -add_subdirectory(graphics) -add_subdirectory(plugins) -add_subdirectory(qt) -add_subdirectory(settings) -add_subdirectory(soundsystem) -add_subdirectory(ui) -add_subdirectory(utility) - -#Create filters -get_target_property(SOURCE_FILES HLAM SOURCES) -source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SOURCE_FILES}) - -# Add this after source_group to avoid errors with root paths -target_sources(HLAM PRIVATE ${CMAKE_BINARY_DIR}/ProjectInfo.hpp) - -# Copy runtime dependencies automatically for dev builds. -add_custom_command(TARGET HLAM POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ - COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ - COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ - COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ - COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ -) - -# Copy plugins so the program can run -copy_qt_dependencies(HLAM Qt5Core_PLUGINS) -copy_qt_dependencies(HLAM Qt5Gui_PLUGINS) -copy_qt_dependencies(HLAM Qt5Widgets_PLUGINS) -copy_qt_dependencies(HLAM Qt5Network_PLUGINS) - -set_property(DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT HLAM) - -install(TARGETS HLAM - RUNTIME DESTINATION .)