Switch to CPM for dependency management
continuous-integration/drone/push Build was killed Details

This commit is contained in:
Deukhoofd 2022-02-05 15:31:10 +01:00
parent af450dceb4
commit 537ae93294
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
4 changed files with 1084 additions and 100 deletions

View File

@ -1,7 +1,8 @@
cmake_minimum_required(VERSION 3.13)
cmake_minimum_required(VERSION 3.16)
include(CheckIPOSupported)
project(pkmnLib)
include(CPM.cmake)
project(pkmnLib)
# We like new stuff, so set the c++ standard to c++20.
set(CMAKE_CXX_STANDARD 20)
@ -13,11 +14,6 @@ option(TESTS "Whether the test executable should be build as well." OFF)
option(STATICC "Whether gcc and stdc++ should be linked statically to the library." OFF)
set(SCRIPT_PROVIDER "angelscript" CACHE STRING "Which script provider to use.")
set(LEVEL_SIZE "8" CACHE STRING "Number of bits to store the level as. Can be 8")
include(CMakeLists.txt.creaturelib.in)
include(CMakeLists.txt.angelscript.in)
include_creaturelib()
include_angelscript()
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options(-fconcepts)
@ -27,6 +23,65 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_link_options(-fuse-ld=lld)
endif ()
execute_process(COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/include)
CPMAddPackage(
NAME Arbutils
GIT_REPOSITORY https://git.p-epsilon.com/Deukhoofd/Arbutils.git
GIT_TAG master
OPTIONS
"SHARED=${SHARED}"
"WINDOWS=${WINDOWS}"
"STATICC=${STATICC}"
)
execute_process(COMMAND ln -sf ${Arbutils_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/include/Arbutils)
CPMAddPackage(
NAME CreatureLib
GIT_REPOSITORY https://git.p-epsilon.com/Deukhoofd/CreatureLib.git
GIT_TAG master
OPTIONS
"SHARED=${SHARED}"
"WINDOWS=${WINDOWS}"
"STATICC=${STATICC}"
)
execute_process(COMMAND ln -sf ${CreatureLib_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/include/CreatureLib)
CPMAddPackage(
NAME CreatureLib
GIT_REPOSITORY https://git.p-epsilon.com/Deukhoofd/CreatureLib.git
GIT_TAG master
OPTIONS
"SHARED=${SHARED}"
"WINDOWS=${WINDOWS}"
"STATICC=${STATICC}"
)
execute_process(COMMAND ln -sf ${CreatureLib_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/include/CreatureLib)
if (SCRIPT_PROVIDER STREQUAL "angelscript")
CPMAddPackage(
NAME Angelscript
GIT_REPOSITORY https://git.p-epsilon.com/Deukhoofd/Angelscript.git
GIT_TAG master
DOWNLOAD_ONLY YES
)
if (Angelscript_ADDED)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . -B ${Angelscript_BINARY_DIR}
-DBUILD_SHARED_LIBS=${SHARED} -DMSVC=${WINDOWS} -DLINK_STD_STATICALLY=${STATICC}
RESULT_VARIABLE result
WORKING_DIRECTORY ${Angelscript_SOURCE_DIR}/angelscript/projects/cmake)
execute_process(COMMAND ${CMAKE_COMMAND} --build ${Angelscript_BINARY_DIR}
RESULT_VARIABLE result
WORKING_DIRECTORY ${Angelscript_SOURCE_DIR}/angelscript/projects/cmake)
endif()
include_directories(${CMAKE_CURRENT_BINARY_DIR}/include)
include_directories(${Angelscript_SOURCE_DIR}/angelscript/include)
link_directories(${Angelscript_BINARY_DIR})
endif()
if (WINDOWS)
SET(CMAKE_SYSTEM_NAME Windows)
ADD_DEFINITIONS(-D WINDOWS=1)
@ -142,7 +197,7 @@ endif ()
if (STATICC)
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--as-needed")
message(STATUS "Linking C library statically")
set(_LINKS ${_LINKS} -Wl,-Bstatic -lm -lgcc -lstdc++ -Wl,-Bdynamic)
set(_LINKS ${_LINKS} -static-libstdc++ -Wl,-Bstatic -lm -lgcc -lstdc++ -Wl,-Bdynamic)
SET(_TESTLINKS ${_TESTLINKS} -Wl,-Bstatic -lm -lgcc -lstdc++ -Wl,-Bdynamic)
else ()
SET(_LINKS ${_LINKS} -Wl,--whole-archive -Wl,--no-whole-archive)

View File

@ -1,49 +0,0 @@
cmake_minimum_required(VERSION 2.8.12)
project(pkmnLib NONE)
include(ExternalProject)
ExternalProject_Add(AngelscriptProj
GIT_REPOSITORY https://git.p-epsilon.com/Deukhoofd/Angelscript.git
GIT_TAG master
PREFIX "${CMAKE_CURRENT_BINARY_DIR}/Angelscript"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)
function(include_angelscript)
configure_file(CMakeLists.txt.angelscript.in Angelscript/download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Angelscript/download)
if (result)
message(FATAL_ERROR "CMake step for angelscript failed: ${result}")
endif ()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Angelscript/download)
if (result)
message(FATAL_ERROR "Build step for angelscript failed: ${result}")
endif ()
SET(BUILD_SHARED_LIBS ${SHARED})
SET(LINK_STD_STATICALLY ${STATICC})
SET(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
if (WINDOWS)
SET(MSVC 1)
endif()
add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/Angelscript/src/AngelscriptProj/angelscript/projects/cmake
${CMAKE_CURRENT_BINARY_DIR}/Angelscript/bin
EXCLUDE_FROM_ALL)
if (WINDOWS)
set_target_properties(angelscript PROPERTIES SUFFIX ".dll")
endif (WINDOWS)
execute_process(COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/Angelscript/include)
include_directories(SYSTEM ${CMAKE_CURRENT_BINARY_DIR}/Angelscript/src/AngelscriptProj/angelscript/include)
endfunction()

View File

@ -1,43 +0,0 @@
cmake_minimum_required(VERSION 2.8.12)
project(pkmnLib NONE)
include(ExternalProject)
ExternalProject_Add(CreatureLibProj
GIT_REPOSITORY https://git.p-epsilon.com/Deukhoofd/CreatureLib
GIT_TAG master
PREFIX "${CMAKE_CURRENT_BINARY_DIR}/CreatureLib"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
CMAKE_ARGS "-DSHARED=${SHARED} -DWINDOWS=${WINDOWS} -DSTATICC=${STATICC}"
)
function(include_creaturelib)
configure_file(CMakeLists.txt.creaturelib.in CreatureLib/download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CreatureLib/download)
if (result)
message(FATAL_ERROR "CMake step for arbutils failed: ${result}")
endif ()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CreatureLib/download)
if (result)
message(FATAL_ERROR "Build step for arbutils failed: ${result}")
endif ()
add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/CreatureLib/src/CreatureLibProj
${CMAKE_CURRENT_BINARY_DIR}/CreatureLib/bin
EXCLUDE_FROM_ALL)
execute_process(COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/CreatureLib/include)
execute_process(COMMAND ln -s ${CMAKE_CURRENT_BINARY_DIR}/CreatureLib/src/CreatureLibProj/src
${CMAKE_CURRENT_BINARY_DIR}/CreatureLib/include/CreatureLib)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/CreatureLib/bin/Arbutils/include ${CMAKE_CURRENT_BINARY_DIR}/CreatureLib/include)
endfunction()

1021
CPM.cmake Normal file

File diff suppressed because it is too large Load Diff