RSE-Terrain/CMakeLists.txt
JackCarterSmith 753089aec8
All checks were successful
JCS-Prod/RSE-Terrain/pipeline/head This commit looks good
Validated conan v2 migration
2024-05-19 10:22:42 +02:00

95 lines
3.5 KiB
CMake

# CMakeLists.txt
####################################################
# Written by JackCarterSmith, 2022
# This code is released under the RSE license.
####################################################
# CMake requirement and general configuration
cmake_minimum_required(VERSION 3.15)
cmake_policy(VERSION 3.15)
set(CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR})
if(DEFINED ENV{MS_COMPATIBLE})
set(CMAKE_GNUtoMS ON) # Enable compatibility level to exported libraries
endif()
# Project definition
if(DEFINED ENV{CI}) # Jenkins CI integration mode
project(rse-terrain VERSION $ENV{CI_VERSION}.$ENV{CI_BUILD_NUMBER} DESCRIPTION "RogueSquadron Extractor - Terrain" LANGUAGES C)
set(RSE_TERRAIN_NAME $ENV{CI_OUTPUT_NAME})
else() # Standalone project mode, should not be used for release.
project(rse-terrain VERSION 2.1.0 DESCRIPTION "RogueSquadron Extractor - Terrain" LANGUAGES C)
set(RSE_TERRAIN_NAME RSETerrain)
endif()
set(RSP_TERRAIN_LIB_NAME RSPTerrain${PROJECT_VERSION_MAJOR}${PROJECT_VERSION_MINOR})
set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables")
set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries")
set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers")
# Compilation option
option(RSPTERRAIN_SHARED "Build shared lib" ON)
option(RSPTERRAIN_STATIC "Build static lib" ON)
option(BUILD_TOOLS "Build lib tools" ON)
# Push compile infos to source
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/RSPTerrainLib/src/config.h @ONLY)
#configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/RSETerrain/src/config.h @ONLY)
# The project is divided in two parts:
# - RSPTerrainLib is the parser library for terrain type data, it's take hmp file as input and output extracted datas.
# It is intended to be used by others apps like rendering engine or others.
# - RSETerrain is the standalone application of the library, take hmp file in argument and output OBJ/MTL file.
# Artists or users can directly use this program to retrieve data in common datas format.
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
unset(RSE_TERRAIN_TARGETS_LIST)
add_subdirectory(RSPTerrainLib)
add_subdirectory(RSETerrain)
if(RSPTERRAIN_SHARED)
list(APPEND RSE_TERRAIN_TARGETS_LIST rsp-terrain-lib)
endif()
if(RSPTERRAIN_STATIC)
list(APPEND RSE_TERRAIN_TARGETS_LIST rsp-terrain-libstatic)
endif()
if(NOT RSE_TERRAIN_TARGETS_LIST)
message(SEND_ERROR
"No library variant selected to build. "
"Please enable at least one of the following options: "
"RSPTERRAIN_STATIC, RSPTERRAIN_SHARED")
endif()
if(BUILD_TOOLS)
list(APPEND RSE_TERRAIN_TARGETS_LIST rse-terrain)
endif()
# GPG signature custom command
#add_custom_command(
# OUTPUT ""
# COMMAND gpg --batch --detach-sign
# -o ${RSE_MOD_NAME}_${CI_SYS_TARGET}.gpg
# ${RSE_MOD_NAME}
# DEPENDS ${RSE_MOD_NAME}
# VERBATIM
#)
# Install dependancies
install(FILES ${PROJECT_BINARY_DIR}/bin/glew32.dll
DESTINATION ${INSTALL_BIN_DIR})
# Install library includes
install(FILES ${RSP_PUBLIC_HRDS} DESTINATION ${INSTALL_INC_DIR})
# Install project artifacts
install(TARGETS ${RSE_TERRAIN_TARGETS_LIST}
RUNTIME DESTINATION ${INSTALL_BIN_DIR}
LIBRARY DESTINATION ${INSTALL_LIB_DIR}
ARCHIVE DESTINATION ${INSTALL_LIB_DIR}
)