Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

Commit

Permalink
Move CMake executable definition to root CMakeLists.txt, move cpp.hint
Browse files Browse the repository at this point in the history
  • Loading branch information
SamVanheer committed Jan 16, 2024
1 parent 1f36485 commit 7ca59e5
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 93 deletions.
98 changes: 97 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
$<$<CXX_COMPILER_ID:MSVC>:
UNICODE
_UNICODE
_CRT_SECURE_NO_WARNINGS
_SCL_SECURE_NO_WARNINGS>
$<$<CXX_COMPILER_ID:GNU,Clang,AppleClang>:
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
$<$<CXX_COMPILER_ID:MSVC>:/MP /fp:strict>
$<$<CXX_COMPILER_ID:GNU,Clang,AppleClang>:-fPIC>)

target_link_options(HLAM
PRIVATE
$<$<CXX_COMPILER_ID:GNU,Clang,AppleClang>:-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 $<TARGET_FILE:OpenAL::OpenAL> $<TARGET_FILE_DIR:HLAM>
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:Qt5::Core> $<TARGET_FILE_DIR:HLAM>
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:Qt5::Gui> $<TARGET_FILE_DIR:HLAM>
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:Qt5::Widgets> $<TARGET_FILE_DIR:HLAM>
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:Qt5::Network> $<TARGET_FILE_DIR:HLAM>
)

# 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 .)
File renamed without changes.
1 change: 0 additions & 1 deletion src/CMakeLists.txt

This file was deleted.

91 changes: 0 additions & 91 deletions src/hlam/CMakeLists.txt

This file was deleted.

0 comments on commit 7ca59e5

Please sign in to comment.