63 lines
1.7 KiB
CMake
63 lines
1.7 KiB
CMake
|
cmake_minimum_required(VERSION 3.10)
|
||
|
project(TerraVisor)
|
||
|
|
||
|
set(CMAKE_CXX_STANDARD 17)
|
||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||
|
|
||
|
# Define output directories for different configurations
|
||
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
||
|
|
||
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}")
|
||
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}")
|
||
|
|
||
|
# Add source files
|
||
|
file(GLOB_RECURSE SOURCES
|
||
|
"${CMAKE_SOURCE_DIR}/src/*.cpp"
|
||
|
)
|
||
|
|
||
|
# Add header files
|
||
|
file(GLOB_RECURSE HEADERS
|
||
|
"${CMAKE_SOURCE}/headers/*.h"
|
||
|
)
|
||
|
|
||
|
# Add shader files
|
||
|
file(GLOB SHADERS
|
||
|
"${CMAKE_SOURCE_DIR}/shaders/*.glsl"
|
||
|
)
|
||
|
|
||
|
# Include directories
|
||
|
include_directories(
|
||
|
${CMAKE_SOURCE_DIR}/include # Third-party headers
|
||
|
${CMAKE_SOURCE_DIR}/headers # Project headers
|
||
|
)
|
||
|
|
||
|
# Link directories for libraries
|
||
|
link_directories(${CMAKE_SOURCE_DIR}/lib)
|
||
|
|
||
|
# Add the executable
|
||
|
add_executable(TerraVisor ${SOURCES} ${HEADERS})
|
||
|
|
||
|
# Link libraries
|
||
|
target_link_libraries(TerraVisor glew32 glfw3 opengl32)
|
||
|
|
||
|
# Include directories for the target
|
||
|
target_include_directories(TerraVisor PRIVATE ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/include/GL ${CMAKE_SOURCE_DIR}/include/GLFW ${CMAKE_SOURCE_DIR}/headers)
|
||
|
|
||
|
# Custom target for shaders
|
||
|
add_custom_target(copy_shaders ALL
|
||
|
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||
|
${CMAKE_SOURCE_DIR}/shaders ${CMAKE_BINARY_DIR}/shaders
|
||
|
)
|
||
|
|
||
|
# 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
|
||
|
add_dependencies(TerraVisor copy_shaders)
|