2024-08-17 22:51:42 +02:00
|
|
|
cmake_minimum_required(VERSION 3.27)
|
|
|
|
project(skeingl)
|
2023-07-23 16:46:30 +02:00
|
|
|
|
2023-07-23 17:46:53 +02:00
|
|
|
# Define platform-specific paths and libraries
|
|
|
|
if(WIN32)
|
2023-07-23 18:21:44 +02:00
|
|
|
# GLFW
|
2023-07-23 17:46:53 +02:00
|
|
|
set(GLFW_PATH "C:/libs/glfw-3.3.8.bin.WIN64")
|
|
|
|
include_directories(${GLFW_PATH}/include)
|
|
|
|
link_directories(${GLFW_PATH}/lib-vc2022)
|
2023-07-23 18:21:44 +02:00
|
|
|
|
2023-07-24 23:31:58 +02:00
|
|
|
# GLEW
|
|
|
|
set(GLEW_PATH "C:/libs/glew-2.2.0")
|
|
|
|
include_directories(${GLEW_PATH}/include)
|
2023-07-26 23:29:51 +02:00
|
|
|
link_directories(${GLEW_PATH}/lib/Release/x64)
|
2023-07-24 23:31:58 +02:00
|
|
|
|
2023-07-23 18:21:44 +02:00
|
|
|
# OpenGL
|
|
|
|
find_package(OpenGL REQUIRED)
|
2023-07-24 23:15:49 +02:00
|
|
|
elseif(UNIX)
|
|
|
|
find_package(PkgConfig REQUIRED)
|
|
|
|
pkg_search_module(GLFW REQUIRED glfw3)
|
2023-07-24 23:31:58 +02:00
|
|
|
find_package(GLEW REQUIRED)
|
2023-07-24 23:15:49 +02:00
|
|
|
find_package(OpenGL REQUIRED)
|
|
|
|
elseif(APPLE)
|
2023-07-28 00:30:56 +02:00
|
|
|
message(FATAL_ERROR "macOS is not supported yet.")
|
2023-07-23 17:46:53 +02:00
|
|
|
endif()
|
2023-07-23 16:46:30 +02:00
|
|
|
|
2024-08-17 22:51:42 +02:00
|
|
|
add_subdirectory(lib/skein)
|
|
|
|
|
2023-07-31 00:08:17 +02:00
|
|
|
add_executable(${PROJECT_NAME}
|
2023-08-06 15:25:44 +02:00
|
|
|
src/main.cpp
|
2023-07-31 00:08:17 +02:00
|
|
|
src/io.cpp
|
2023-08-02 01:52:04 +02:00
|
|
|
src/icosphere.cpp
|
2023-07-31 00:08:17 +02:00
|
|
|
src/gfx.cpp
|
2024-08-17 22:51:42 +02:00
|
|
|
src/orbitvisualizer.cpp
|
2024-08-18 02:43:57 +02:00
|
|
|
src/orbitervisualizer.cpp
|
2024-02-26 21:00:59 +01:00
|
|
|
src/orbiter.cpp
|
2023-10-06 00:25:37 +02:00
|
|
|
src/widget.cpp
|
2023-07-31 00:08:17 +02:00
|
|
|
)
|
2023-07-23 17:46:53 +02:00
|
|
|
|
|
|
|
if(WIN32)
|
2023-07-26 23:29:51 +02:00
|
|
|
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
|
|
"${GLEW_PATH}/bin/Release/x64/glew32.dll"
|
|
|
|
$<TARGET_FILE_DIR:${PROJECT_NAME}>
|
|
|
|
)
|
|
|
|
|
2023-07-23 17:46:53 +02:00
|
|
|
target_link_libraries(${PROJECT_NAME} glfw3)
|
2023-07-26 23:29:51 +02:00
|
|
|
target_link_libraries(${PROJECT_NAME} glew32)
|
2023-07-24 23:31:58 +02:00
|
|
|
target_include_directories(${PROJECT_NAME} PRIVATE ${GLEW_INCLUDE_DIRS})
|
2023-07-23 18:21:44 +02:00
|
|
|
target_link_libraries(${PROJECT_NAME} OpenGL::GL)
|
2024-08-17 22:51:42 +02:00
|
|
|
target_link_libraries(${PROJECT_NAME} skein)
|
2023-07-24 23:15:49 +02:00
|
|
|
elseif(UNIX)
|
|
|
|
include_directories(${GLFW_INCLUDE_DIRS})
|
|
|
|
target_link_libraries(${PROJECT_NAME} ${GLFW_LIBRARIES})
|
2023-07-24 23:31:58 +02:00
|
|
|
target_link_libraries(${PROJECT_NAME} GLEW::GLEW)
|
2023-07-24 23:15:49 +02:00
|
|
|
target_link_libraries(${PROJECT_NAME} OpenGL::GL)
|
2024-08-17 22:51:42 +02:00
|
|
|
target_link_libraries(${PROJECT_NAME} skein)
|
2023-07-24 23:15:49 +02:00
|
|
|
endif()
|
2023-07-24 23:54:37 +02:00
|
|
|
|
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/vert.glsl
|
2024-08-17 22:51:42 +02:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/vert.glsl COPYONLY)
|
2023-08-06 13:08:49 +02:00
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/frag_lit.glsl
|
2024-08-17 22:51:42 +02:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/frag_lit.glsl COPYONLY)
|
2023-08-06 13:08:49 +02:00
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/frag_unlit.glsl
|
2024-08-17 22:51:42 +02:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/frag_unlit.glsl COPYONLY)
|
2023-07-25 23:39:26 +02:00
|
|
|
|
|
|
|
# Append Git version to built executable after it has been built
|
|
|
|
find_package(Git)
|
|
|
|
if (GIT_FOUND)
|
|
|
|
if (WIN32)
|
|
|
|
set(TARGET_EXTENSION ".exe")
|
|
|
|
elseif(UNIX)
|
|
|
|
set(TARGET_EXTENSION "")
|
|
|
|
endif()
|
|
|
|
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
|
|
|
|
COMMAND ${CMAKE_COMMAND}
|
2024-08-17 22:51:42 +02:00
|
|
|
-DTARGET_DIR=$<TARGET_FILE_DIR:${PROJECT_NAME}>
|
|
|
|
-DPROJECT_NAME=${PROJECT_NAME}
|
|
|
|
-DTARGET_EXTENSION=${TARGET_EXTENSION}
|
|
|
|
-P ${CMAKE_CURRENT_SOURCE_DIR}/add_git_version_to_executable.cmake
|
2023-07-25 23:39:26 +02:00
|
|
|
)
|
|
|
|
else()
|
|
|
|
message("Git not found - will not rename the exectuable.")
|
|
|
|
endif()
|
2023-07-27 01:04:23 +02:00
|
|
|
|
2024-08-17 22:51:42 +02:00
|
|
|
#target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/lib/skein/include)
|
|
|
|
|
2023-07-31 02:14:23 +02:00
|
|
|
# Include header-only libraries
|
2023-07-27 01:04:23 +02:00
|
|
|
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/lib/astro/include)
|
2024-08-17 22:51:42 +02:00
|
|
|
# TODO: we really only want to include skein as a library, without concerning ourselves with skein's libraries
|
2023-07-31 02:14:23 +02:00
|
|
|
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/lib/glm)
|
2023-07-27 01:04:23 +02:00
|
|
|
|