Added conan package support
All checks were successful
JCS-Prod/RSE-Terrain/pipeline/pr-master This commit looks good
JCS-Prod/RSE-Terrain/pipeline/head This commit looks good

This commit is contained in:
JackCarterSmith 2022-09-14 18:48:03 +02:00
parent e3b372b6b5
commit 6cba3cb768
Signed by: JackCarterSmith
GPG Key ID: 832E52F4E23F8F24
5 changed files with 181 additions and 38 deletions

View File

@ -26,8 +26,14 @@ endif()
set(RSP_TERRAIN_LIB_NAME RSPTerrain${PROJECT_VERSION_MAJOR}${PROJECT_VERSION_MINOR})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
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)
# Push compile infos to source
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/RSPTerrainLib/src/config.h @ONLY)
@ -42,8 +48,24 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_SOURCE_DI
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(BUILD_TOOLS)
set(RSE_TERRAIN_TARGETS_LIST rse-terrain)
endif()
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()
# GPG signature custom command
@ -57,22 +79,16 @@ add_subdirectory(RSETerrain)
#)
# Install project executable
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")
if(RSPTERRAIN_SHARED)
set(RSE_TERRAIN_TARGETS_LIST rse-terrain rsp-terrain-lib rsp-terrain-libstatic)
else()
set(RSE_TERRAIN_TARGETS_LIST rse-terrain rsp-terrain-libstatic)
endif()
# 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}
)
# Install library includes
install(FILES ${RSP_PUBLIC_HRDS} DESTINATION ${INSTALL_INC_DIR})
# Install dependancies
install(FILES ${PROJECT_BINARY_DIR}/bin/glew32.dll ${PROJECT_BINARY_DIR}/bin/libpng16.dll
DESTINATION ${INSTALL_BIN_DIR})

2
Jenkinsfile vendored
View File

@ -5,7 +5,7 @@ pipeline {
}
environment {
CI_OUTPUT_NAME = "RSETerrain"
CI_VERSION = "2.0.3"
CI_VERSION = "2.0.4"
CI_BUILD_NUMBER = "$BUILD_NUMBER"
}
stages {

View File

@ -15,8 +15,8 @@ add_definitions(-DCONF_NO_GL) # Used for obj-lib to not compile GL part
# Import needed packages and references their include path
find_package(PNG 1.6.37 REQUIRED)
include_directories(${PNG_INCLUDE_DIR})
#find_package(GLEW REQUIRED) # Enable when GL rendering is ready
#include_directories(${GLEW_INCLUDE_DIR})
find_package(GLEW REQUIRED) # Enable when GL rendering is ready
include_directories(${GLEW_INCLUDE_DIR})
# Define src/headers files
@ -37,11 +37,16 @@ set_property(TARGET rse-terrain PROPERTY C_STANDARD 90)
#target_include_directories(rse-terrain PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
set_target_properties(rse-terrain PROPERTIES OUTPUT_NAME ${RSE_TERRAIN_NAME})
# Link externals libraries to the linker
if(MSVC)
# msvc does not append 'lib' - do it here to have consistent name
set_target_properties(rse-terrain PROPERTIES IMPORT_PREFIX "lib")
target_link_libraries(rse-terrain PRIVATE rsp-terrain-libstatic ${PNG_LIBRARIES} ${GLEW_LIBRARIES})
else()
target_link_libraries(rse-terrain PRIVATE rsp-terrain-libstatic ${PNG_LIBRARIES} ${GLEW_LIBRARIES} m)
elseif(UNIX)
set(AUX_LIBS m)# add math.lib for GL processing
endif()
# Link externals libraries to the linker
if(RSPTERRAIN_SHARED)
target_link_libraries(rse-terrain PRIVATE rsp-terrain-lib ${PNG_LIBRARIES} ${GLEW_LIBRARIES} ${AUX_LIBS})
elseif(RSPTERRAIN_STATIC)
target_link_libraries(rse-terrain PRIVATE rsp-terrain-libstatic ${PNG_LIBRARIES} ${GLEW_LIBRARIES} ${AUX_LIBS})
endif()

View File

@ -32,14 +32,18 @@ endif()
if(RSPTERRAIN_SHARED)
add_library(rsp-terrain-lib SHARED ${RSP_TERRAIN_SOURCES})
set_property(TARGET rsp-terrain-lib PROPERTY C_STANDARD 90)
set_target_properties(rsp-terrain-lib PROPERTIES VERSION 2.1.0)
target_include_directories(rsp-terrain-lib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
set_target_properties(rsp-terrain-lib PROPERTIES OUTPUT_NAME ${RSP_TERRAIN_LIB_NAME})
set_target_properties(rsp-terrain-lib PROPERTIES DEFINE_SYMBOL RSPTERRAIN_DLL)
set_target_properties(rsp-terrain-lib PROPERTIES OUTPUT_NAME "${RSP_TERRAIN_LIB_NAME}")
if(WIN32)
set_target_properties(rsp-terrain-lib PROPERTIES DEFINE_SYMBOL RSPTERRAIN_DLL)
endif()
if(MSVC)
# msvc does not append 'lib' - do it here to have consistent name
# msvc does not append 'lib' - do it here to have consistent name
if(MSVC)
set_target_properties(rsp-terrain-lib PROPERTIES PREFIX "lib")
set_target_properties(rsp-terrain-lib PROPERTIES IMPORT_PREFIX "lib")
endif()
@ -47,21 +51,52 @@ endif()
# Declare the static library instance
add_library(rsp-terrain-libstatic STATIC ${RSP_TERRAIN_SOURCES})
set_property(TARGET rsp-terrain-libstatic PROPERTY C_STANDARD 90)
if(RSPTERRAIN_STATIC)
add_library(rsp-terrain-libstatic STATIC ${RSP_TERRAIN_SOURCES})
set_property(TARGET rsp-terrain-libstatic PROPERTY C_STANDARD 90)
target_include_directories(rsp-terrain-libstatic PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_include_directories(rsp-terrain-libstatic PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
if(NOT MSVC)
set_target_properties(rsp-terrain-libstatic PROPERTIES OUTPUT_NAME "${RSP_TERRAIN_LIB_NAME}")
set_target_properties(rsp-terrain-libstatic PROPERTIES CLEAN_DIRECT_OUTPUT 1)
else()
set_target_properties(rsp-terrain-libstatic PROPERTIES OUTPUT_NAME "${RSP_TERRAIN_LIB_NAME}_static")
set_target_properties(rsp-terrain-libstatic PROPERTIES CLEAN_DIRECT_OUTPUT 1)
endif()
# MSVC doesn't use a different file extension for shared vs. static
# libs. We are able to change OUTPUT_NAME to remove the _static
# for all other platforms.
if(NOT MSVC)
set_target_properties(rsp-terrain-libstatic PROPERTIES OUTPUT_NAME "${RSP_TERRAIN_LIB_NAME}")
set_target_properties(rsp-terrain-libstatic PROPERTIES CLEAN_DIRECT_OUTPUT 1)
else()
set_target_properties(rsp-terrain-libstatic PROPERTIES OUTPUT_NAME "${RSP_TERRAIN_LIB_NAME}_static")
set_target_properties(rsp-terrain-libstatic PROPERTIES CLEAN_DIRECT_OUTPUT 1)
endif()
if(MSVC)
# msvc does not append 'lib' - do it here to have consistent name
set_target_properties(rsp-terrain-libstatic PROPERTIES PREFIX "lib")
set_target_properties(rsp-terrain-libstatic PROPERTIES IMPORT_PREFIX "lib")
if(MSVC)
set_target_properties(rsp-terrain-libstatic PROPERTIES PREFIX "lib")
endif()
endif()
include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/create_symlink.cmake)
# Install libraries with OS specific name fix
if(RSPTERRAIN_SHARED)
# Create a symlink for libRSPTerrain.dll.a => libRSPTerrainXX.dll.a on Cygwin/MinGW
if(CYGWIN OR MINGW)
create_lib_symlink(libRSPTerrain${CMAKE_IMPORT_LIBRARY_SUFFIX} TARGET rsp-terrain-lib)
install(FILES $<TARGET_LINKER_FILE_DIR:rsp-terrain-lib>/libRSPTerrain${CMAKE_IMPORT_LIBRARY_SUFFIX}
DESTINATION ${INSTALL_LIB_DIR})
endif()
if(NOT WIN32)
create_lib_symlink(libRSPTerrain${CMAKE_SHARED_LIBRARY_SUFFIX} TARGET rsp-terrain-lib)
install(FILES $<TARGET_LINKER_FILE_DIR:rsp-terrain-lib>/libRSPTerrain${CMAKE_SHARED_LIBRARY_SUFFIX}
DESTINATION ${INSTALL_LIB_DIR})
endif()
endif()
if(RSPTERRAIN_STATIC)
if(NOT WIN32 OR CYGWIN OR MINGW)
create_lib_symlink(libRSPTerrain${CMAKE_STATIC_LIBRARY_SUFFIX} TARGET rsp-terrain-libstatic)
install(FILES $<TARGET_LINKER_FILE_DIR:rsp-terrain-libstatic>/libRSPTerrain${CMAKE_STATIC_LIBRARY_SUFFIX}
DESTINATION ${INSTALL_LIB_DIR})
endif()
endif()

View File

@ -0,0 +1,87 @@
# Set a variable with CMake code which:
# Creates a symlink from src to dest (if possible) or alternatively
# copies if different.
include(CMakeParseArguments)
function(create_symlink DEST_FILE)
cmake_parse_arguments(S "" "FILE;TARGET" "" ${ARGN})
if(NOT S_TARGET AND NOT S_FILE)
message(FATAL_ERROR "create_symlink: Missing TARGET or FILE argument")
endif()
if(S_TARGET AND S_FILE)
message(FATAL_ERROR "create_symlink: Both source file ${S_FILE} and build target ${S_TARGET} arguments are present; can only have one.")
endif()
if(S_FILE)
# If we don't need to symlink something that's coming from a build target,
# we can go ahead and symlink/copy at configure time.
if(CMAKE_HOST_WIN32 AND NOT CYGWIN)
execute_process(
COMMAND "${CMAKE_COMMAND}" -E copy_if_different ${S_FILE} ${DEST_FILE}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
else()
execute_process(
COMMAND ${CMAKE_COMMAND} -E create_symlink ${S_FILE} ${DEST_FILE}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
endif()
endif()
if(S_TARGET)
# We need to use generator expressions, which can be a bit tricky, so for
# simplicity make the symlink a POST_BUILD step and use the TARGET
# signature of add_custom_command.
if(CMAKE_HOST_WIN32 AND NOT CYGWIN)
add_custom_command(TARGET ${S_TARGET} POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy_if_different $<TARGET_LINKER_FILE_NAME:${S_TARGET}> $<TARGET_LINKER_FILE_DIR:${S_TARGET}>/${DEST_FILE})
else()
add_custom_command(TARGET ${S_TARGET} POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E create_symlink $<TARGET_LINKER_FILE_NAME:${S_TARGET}> $<TARGET_LINKER_FILE_DIR:${S_TARGET}>/${DEST_FILE})
endif()
endif()
endfunction()
function(create_lib_symlink DEST_FILE)
cmake_parse_arguments(S "" "FILE;TARGET" "" ${ARGN})
if(NOT S_TARGET AND NOT S_FILE)
message(FATAL_ERROR "create_symlink: Missing TARGET or FILE argument")
endif()
if(S_TARGET AND S_FILE)
message(FATAL_ERROR "create_symlink: Both source file ${S_FILE} and build target ${S_TARGET} arguments are present; can only have one.")
endif()
if(S_FILE)
# If we don't need to symlink something that's coming from a build target,
# we can go ahead and symlink/copy at configure time.
if(CMAKE_HOST_WIN32 AND NOT CYGWIN)
execute_process(
COMMAND "${CMAKE_COMMAND}" -E copy_if_different ${S_FILE} ${DEST_FILE}
WORKING_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
else()
execute_process(
COMMAND ${CMAKE_COMMAND} -E create_symlink ${S_FILE} ${DEST_FILE}
WORKING_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
endif()
endif()
if(S_TARGET)
# We need to use generator expressions, which can be a bit tricky, so for
# simplicity make the symlink a POST_BUILD step and use the TARGET
# signature of add_custom_command.
if(CMAKE_HOST_WIN32 AND NOT CYGWIN)
add_custom_command(TARGET ${S_TARGET} POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy_if_different ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/$<TARGET_LINKER_FILE_NAME:${S_TARGET}> $<TARGET_LINKER_FILE_DIR:${S_TARGET}>/${DEST_FILE})
else()
add_custom_command(TARGET ${S_TARGET} POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E create_symlink ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/$<TARGET_LINKER_FILE_NAME:${S_TARGET}> $<TARGET_LINKER_FILE_DIR:${S_TARGET}>/${DEST_FILE})
endif()
endif()
endfunction()