2024-08-10 19:12:21 -04:00
|
|
|
cmake_minimum_required(VERSION 3.10)
|
|
|
|
project(TerraVisor)
|
|
|
|
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
|
2024-08-10 21:27:13 -04:00
|
|
|
# Find packages using vcpkg
|
|
|
|
find_package(GLEW CONFIG REQUIRED)
|
|
|
|
find_package(glfw3 CONFIG REQUIRED)
|
2024-08-12 17:06:33 -04:00
|
|
|
find_package(glm CONFIG REQUIRED)
|
2024-08-11 12:12:26 -04:00
|
|
|
find_package(assimp CONFIG REQUIRED)
|
2024-08-24 00:11:20 -04:00
|
|
|
find_package(TIFF REQUIRED)
|
2024-08-10 21:27:13 -04:00
|
|
|
|
2024-08-23 18:59:16 -04:00
|
|
|
# Set Debug and Release directories
|
2024-08-10 19:12:21 -04:00
|
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}")
|
|
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}")
|
|
|
|
|
|
|
|
# Add source files
|
2024-08-23 18:51:43 -04:00
|
|
|
file(GLOB_RECURSE SOURCES "${CMAKE_SOURCE_DIR}/source/*.cpp")
|
|
|
|
file(GLOB_RECURSE HEADERS "${CMAKE_SOURCE_DIR}/include/*.h")
|
|
|
|
file(GLOB SHADERS "${CMAKE_SOURCE_DIR}/shaders/*.glsl")
|
2024-08-11 14:52:19 -04:00
|
|
|
file(GLOB IMGUI_SOURCES
|
|
|
|
"${CMAKE_SOURCE_DIR}/imgui/*.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/imgui/backends/imgui_impl_glfw.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/imgui/backends/imgui_impl_opengl3.cpp"
|
|
|
|
)
|
2024-08-23 23:35:47 -04:00
|
|
|
file(GLOB FREEIMAGE_HEADER "${CMAKE_SOURCE_DIR}/dependencies/FreeImage/include/*.h")
|
2024-08-11 14:52:19 -04:00
|
|
|
|
2024-08-10 19:12:21 -04:00
|
|
|
# Add the executable
|
2024-08-23 23:35:47 -04:00
|
|
|
add_executable(TerraVisor ${SOURCES} ${HEADERS} ${IMGUI_SOURCES} ${FREEIMAGE_HEADER})
|
2024-08-10 19:12:21 -04:00
|
|
|
|
2024-08-23 18:51:43 -04:00
|
|
|
# Include directories (handled by find_package now)
|
2024-08-11 14:52:19 -04:00
|
|
|
include_directories(
|
2024-08-11 15:09:37 -04:00
|
|
|
${CMAKE_SOURCE_DIR}/include
|
2024-08-11 14:52:19 -04:00
|
|
|
${CMAKE_SOURCE_DIR}/imgui
|
2024-08-22 16:50:38 -04:00
|
|
|
${CMAKE_SOURCE_DIR}/imgui/backends
|
2024-08-23 23:35:47 -04:00
|
|
|
${CMAKE_SOURCE_DIR}/dependencies/FreeImage/include
|
2024-08-11 14:52:19 -04:00
|
|
|
)
|
2024-08-10 19:12:21 -04:00
|
|
|
|
2024-08-23 23:35:47 -04:00
|
|
|
link_directories(${CMAKE_SOURCE_DIR}/dependencies/FreeImage/lib)
|
|
|
|
|
2024-08-10 21:27:13 -04:00
|
|
|
# Link libraries using vcpkg
|
2024-08-24 00:06:28 -04:00
|
|
|
if (WIN32)
|
|
|
|
target_link_libraries(TerraVisor PRIVATE GLEW::GLEW glfw glm::glm assimp::assimp ${CMAKE_SOURCE_DIR}/dependencies/FreeImage/lib/FreeImage.lib)
|
2024-08-24 00:07:37 -04:00
|
|
|
else()
|
2024-08-24 00:11:20 -04:00
|
|
|
target_link_libraries(TerraVisor PRIVATE GLEW::GLEW glfw glm::glm assimp::assimp TIFF::TIFF ${CMAKE_SOURCE_DIR}/dependencies/FreeImage/lib/linux/libfreeimage.a)
|
2024-08-24 00:07:37 -04:00
|
|
|
endif()
|
2024-08-10 19:12:21 -04:00
|
|
|
|
2024-08-23 18:51:43 -04:00
|
|
|
# Custom targets
|
2024-08-10 19:12:21 -04:00
|
|
|
add_custom_target(copy_shaders ALL
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
|
|
|
${CMAKE_SOURCE_DIR}/shaders ${CMAKE_BINARY_DIR}/shaders
|
|
|
|
)
|
2024-08-19 10:28:26 -04:00
|
|
|
add_custom_target(copy_hgt ALL
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
|
|
|
${CMAKE_SOURCE_DIR}/hgt ${CMAKE_BINARY_DIR}/hgt
|
|
|
|
)
|
2024-08-23 23:35:47 -04:00
|
|
|
# Set paths for FreeImage DLL
|
|
|
|
set(FREEIMAGE_DLL_PATH "${CMAKE_SOURCE_DIR}/dependencies/FreeImage/bin/FreeImage.dll")
|
|
|
|
|
|
|
|
# Add custom command to copy FreeImage.dll to the output directory for both Debug and Release
|
|
|
|
add_custom_command(TARGET TerraVisor POST_BUILD
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
|
|
${FREEIMAGE_DLL_PATH}
|
|
|
|
$<TARGET_FILE_DIR:TerraVisor>
|
|
|
|
)
|
2024-08-19 10:28:26 -04:00
|
|
|
|
2024-08-10 19:12:21 -04:00
|
|
|
# Set subsystem based on build type
|
|
|
|
if (WIN32)
|
|
|
|
if (CMAKE_BUILD_TYPE STREQUAL "Release")
|
|
|
|
set_target_properties(TerraVisor PROPERTIES LINK_FLAGS "-Wl,--subsystem,windows")
|
|
|
|
else()
|
|
|
|
set_target_properties(TerraVisor PROPERTIES LINK_FLAGS "-Wl,--subsystem,console")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Ensure shaders are copied before building the executable
|
2024-08-19 10:28:26 -04:00
|
|
|
add_dependencies(TerraVisor copy_shaders copy_hgt)
|