mirror of
https://github.com/Vita3K/Vita3K.git
synced 2026-07-11 01:34:23 +02:00
Improve build procedure
- Integrates Boost build procedure into the CMake configure process - Adds CMake toolchain files for easier environment setup
This commit is contained in:
+59
-4
@@ -1,6 +1,10 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(Vita3K)
|
||||
|
||||
# Detects the amount of processors of the host machine and forwards the restult to CPU_COUNT
|
||||
include(ProcessorCount)
|
||||
ProcessorCount(CPU_COUNT)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
@@ -16,7 +20,54 @@ endif()
|
||||
|
||||
enable_testing()
|
||||
|
||||
macro(pre_configure_boost)
|
||||
############################
|
||||
########## Boost ###########
|
||||
############################
|
||||
|
||||
# Configures Boost
|
||||
macro(boost_configure)
|
||||
# Sets the location of the source root and the binary installation path for Boost
|
||||
# Building Boost right at the CMake binary path should allow to build Vita3K for different target platforms
|
||||
# without having to delete the boost-build folder each time the target platform changes
|
||||
set(BOOST_SOURCEDIR "${CMAKE_SOURCE_DIR}/external/boost")
|
||||
set(BOOST_INSTALLDIR "${CMAKE_BINARY_DIR}/external/boost/")
|
||||
|
||||
if (WIN32)
|
||||
execute_process(
|
||||
COMMAND ${BOOST_SOURCEDIR}/bootstrap.bat
|
||||
WORKING_DIRECTORY ${BOOST_SOURCEDIR}
|
||||
)
|
||||
elseif(UNIX)
|
||||
execute_process(
|
||||
COMMAND chmod +x ${BOOST_SOURCEDIR}/tools/build/src/engine/build.sh
|
||||
COMMAND sh ${BOOST_SOURCEDIR}/bootstrap.sh
|
||||
WORKING_DIRECTORY ${BOOST_SOURCEDIR}
|
||||
)
|
||||
endif()
|
||||
endmacro(boost_configure)
|
||||
|
||||
# Compiles Boost
|
||||
macro(boost_compile)
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL Windows)
|
||||
execute_process(
|
||||
COMMAND ${BOOST_SOURCEDIR}/b2 -j${CPU_COUNT} --build-dir=${BOOST_INSTALLDIR} --stagedir=${BOOST_INSTALLDIR} toolset=msvc stage
|
||||
WORKING_DIRECTORY ${BOOST_SOURCEDIR}
|
||||
)
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
|
||||
execute_process(
|
||||
COMMAND ${BOOST_SOURCEDIR}/b2 -j${CPU_COUNT} --build-dir=${BOOST_INSTALLDIR} --stagedir=${BOOST_INSTALLDIR} stage
|
||||
WORKING_DIRECTORY ${BOOST_SOURCEDIR}
|
||||
)
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL Linux)
|
||||
execute_process(
|
||||
COMMAND ${BOOST_SOURCEDIR}/b2 --ignore-site-config -j${CPU_COUNT} --build-dir=${BOOST_INSTALLDIR} --stagedir=${BOOST_INSTALLDIR} stage
|
||||
WORKING_DIRECTORY ${BOOST_SOURCEDIR}
|
||||
)
|
||||
endif()
|
||||
endmacro(boost_compile)
|
||||
|
||||
# Adjusts CMake paths to enable Boost as a findable package for other dependencies in the project
|
||||
macro(boost_set_paths)
|
||||
set (Boost_USE_STATIC_LIBS ON)
|
||||
find_package(Boost COMPONENTS filesystem system program_options QUIET)
|
||||
|
||||
@@ -27,16 +78,20 @@ macro(pre_configure_boost)
|
||||
message("Setting up ext-boost environment variables")
|
||||
set(BOOST_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/external/boost")
|
||||
set(BOOST_INCLUDEDIR "${BOOST_ROOT}/boost")
|
||||
set(BOOST_LIBRARYDIR "${CMAKE_CURRENT_SOURCE_DIR}/external/boost-build/lib")
|
||||
set(BOOST_LIBRARYDIR "${BOOST_INSTALLDIR}/lib")
|
||||
endif()
|
||||
|
||||
message("Using Boost_VERSION: ${BOOST_ROOT}")
|
||||
message("Using Boost_INCLUDE_DIRS: ${BOOST_INCLUDEDIR}")
|
||||
message("Using Boost_LIBRARY_DIRS: ${BOOST_LIBRARYDIR}")
|
||||
endmacro(pre_configure_boost)
|
||||
endmacro(boost_set_paths)
|
||||
|
||||
|
||||
|
||||
if(NOT CI)
|
||||
pre_configure_boost()
|
||||
boost_configure()
|
||||
boost_compile()
|
||||
boost_set_paths()
|
||||
endif()
|
||||
|
||||
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/GetStandard.cmake")
|
||||
|
||||
Reference in New Issue
Block a user