Skip to content

Commit

Permalink
use CPM CMake to fetch and build boost
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-f committed Oct 3, 2024
1 parent ce01dcb commit bc12ae8
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 76 deletions.
7 changes: 0 additions & 7 deletions .github/workflows/sub_buildWindows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ jobs:
CCACHE_LOGFILE: C:/logs/ccache.log
## Have to use C:\ because not enough space on workspace drive
builddir: C:/ISIMPA/build/release/
libpackdir: C:/ISIMPA/libpack/
ccachebindir: C:/ISIMPA/ccache/
logdir: C:/logs/
reportdir: C:/report/
Expand All @@ -80,7 +79,6 @@ jobs:
run: |
mkdir ${{ env.CCACHE_DIR }}
mkdir ${{ env.ccachebindir }}
mkdir ${{ env.libpackdir }}
mkdir ${{ env.builddir }}
mkdir ${{ env.logdir }}
mkdir ${{ env.reportdir }}
Expand All @@ -96,10 +94,6 @@ jobs:
uses: ./.github/workflows/actions/windows/getCcache
with:
ccachebindir: ${{ env.ccachebindir }}
- name: Get Libpack
uses: ./.github/workflows/actions/windows/getLibpack
with:
libpackdir: ${{ env.libpackdir }}
- name: Restore compiler cache
uses: actions/cache@v4
with:
Expand All @@ -120,7 +114,6 @@ jobs:
-DCPM_SOURCE_CACHE=${{ env.CPM_SOURCE_CACHE }}
-DCMAKE_VS_NO_COMPILE_BATCHING=ON
-DCMAKE_BUILD_TYPE=Release
-DISIMPA_LIBPACK_DIR="${{ env.libpackdir }}"
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2
- name: Compiling sources
Expand Down
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ project (isimpa VERSION 1.3.4)

# a better way to load dependencies
include(cmake/CPM.cmake)
# download boost source and compile using CPM
include(cmake/SetupBoost.cmake)

# convert path of a .lib file into a .dll file
# findboost does not store .dll locations
Expand Down Expand Up @@ -86,6 +88,8 @@ add_subdirectory(src/tetgen)
add_subdirectory (src/spps)
if(NOT SKIPISIMPA)
add_subdirectory (src/isimpa)
else()
message (STATUS "Skip building GUI")
endif()

# custom target for CLion "make install"
Expand Down
20 changes: 20 additions & 0 deletions cmake/SetupBoost.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
macro(SetupBoost)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
CPMAddPackage(
NAME Boost
VERSION 1.86.0
URL https://github.com/boostorg/boost/releases/download/boost-1.86.0/boost-1.86.0-cmake.tar.xz
URL_HASH SHA256=2c5ec5edcdff47ff55e27ed9560b0a0b94b07bd07ed9928b476150e16b0efc57
OPTIONS "BOOST_ENABLE_CMAKE ON" "BOOST_INCLUDE_LIBRARIES system\\\;algorithm\\\;random\\\;filesystem\\\;regex\\\;python\\\;numeric/conversion\\\;test" # Note the escapes!
)
else()
find_package (Threads)
CPMAddPackage(
NAME Boost
VERSION 1.86.0
URL https://github.com/boostorg/boost/releases/download/boost-1.86.0/boost-1.86.0-cmake.tar.xz
URL_HASH SHA256=2c5ec5edcdff47ff55e27ed9560b0a0b94b07bd07ed9928b476150e16b0efc57
OPTIONS "BOOST_ENABLE_CMAKE ON" "BOOST_INCLUDE_LIBRARIES system\\\;algorithm\\\;random\\\;filesystem\\\;regex\\\;thread\\\;chrono\\\;test\\\;date_time\\\;python\\\;numeric" # Note the escapes!
)
endif()
endmacro(SetupBoost)
1 change: 0 additions & 1 deletion src/VolumetricMeshRepair/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ set(VMR_SOURCE_FILES
# DEPENDENCY & EXECUTABLE (OR LIB)
#---------------------------------------#

find_package(Boost COMPONENTS system filesystem regex REQUIRED)
link_directories( ${Boost_LIBRARY_DIRS} )

# Set Properties->General->Configuration Type to Application
Expand Down
4 changes: 2 additions & 2 deletions src/ctr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ set(CT_SOURCE_FILES
# DEPENDENCY & EXECUTABLE (OR LIB)
#---------------------------------------#

set(Boost_USE_STATIC_LIBS OFF)
find_package(Boost COMPONENTS system filesystem regex REQUIRED)
set(Boost_USE_STATIC_LIBS OFF)

link_directories( ${Boost_LIBRARY_DIRS} )
include_directories( ${Boost_INCLUDE_DIRS} )

Expand Down
43 changes: 11 additions & 32 deletions src/isimpa/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ set_property(SOURCE data_manager/python_interface/py_ui_module/element_pywrap.cp
configure_file(data_manager/appconfig_version.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/generated/appconfig_version.cpp )

set(Boost_USE_STATIC_LIBS OFF)
find_package(Boost REQUIRED COMPONENTS system python filesystem regex random)

link_directories( ${Boost_LIBRARY_DIRS} )

# Set Properties->General->Configuration Type to Application
Expand Down Expand Up @@ -468,38 +468,17 @@ SET(CMAKE_EXE_LINKER_FLAGS

# add wxWidgets as dependency

find_package(wxWidgets)

if(wxWidgets_FOUND)

if(CMAKE_BUILD_TYPE STREQUAL Debug)
if(NOT ${wxWidgets_CONFIGURATION} MATCHES .*d$ )
set(wxWidgets_CONFIGURATION ${wxWidgets_CONFIGURATION}d)
endif()
else()
if(${wxWidgets_CONFIGURATION} MATCHES .*d$ )
string(LENGTH ${wxWidgets_CONFIGURATION} BUILD_STR_SIZE)
MATH(EXPR BUILD_STR_SIZE "${BUILD_STR_SIZE}-1")
string(SUBSTRING ${wxWidgets_CONFIGURATION} 0 ${BUILD_STR_SIZE} wxWidgets_CONFIGURATION)
endif()
endif()
set(USING_CPM true)
set(BUILD_SHARED_LIBS OFF)
set(CPM_DOWNLOAD_VERSION 0.34.0)

find_package(wxWidgets COMPONENTS core base xml gl aui adv html REQUIRED)
include(${CPM_DOWNLOAD_LOCATION})

include(${wxWidgets_USE_FILE})
else(NOT wxWidgets_FOUND)
set(USING_CPM true)
set(BUILD_SHARED_LIBS OFF)
set(CPM_DOWNLOAD_VERSION 0.34.0)

include(${CPM_DOWNLOAD_LOCATION})

CPMAddPackage(
NAME wxWidgets
GIT_REPOSITORY https://github.com/wxWidgets/wxWidgets
GIT_TAG v3.2.1
)
endif()
CPMAddPackage(
NAME wxWidgets
GIT_REPOSITORY https://github.com/wxWidgets/wxWidgets
GIT_TAG v3.2.1
)

# Find package for buildingfind_package(Python3 COMPONENTS Interpreter Development)
FIND_PACKAGE(PythonLibs "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}" REQUIRED)
Expand All @@ -512,7 +491,7 @@ include_directories(${wxWidgets_SOURCE_DIR})
include_directories(${PYTHON_INCLUDE_PATH})

# Properties->Linker->Input->Additional Dependencies
target_link_libraries(isimpa lib_interface Boost::python Boost::random ${PYTHON_LIBRARIES})
target_link_libraries(isimpa lib_interface ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})

if(WIN32 AND MSVC)
target_link_libraries(isimpa ${PYTHON_LIBRARY_RELEASE})
Expand Down
19 changes: 8 additions & 11 deletions src/lib_interface/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,6 @@ source_group( "tools" FILES ${TOOLS_SOURCES} )
#---------------------------------------#

set(Boost_USE_STATIC_LIBS OFF)
find_package(Boost COMPONENTS REQUIRED system filesystem regex)
link_directories( ${Boost_LIBRARY_DIRS} )
include_directories( ${Boost_INCLUDE_DIRS} )

add_library(lib_interface
${LIBINTERFACE_SOURCES}
Expand All @@ -134,10 +131,11 @@ add_library(lib_interface
# Creates a folder "libraries" and adds target project (lib_interface.vcproj) under it
set_property(TARGET lib_interface PROPERTY FOLDER "libraries")

target_link_libraries (lib_interface
${Boost_FILESYSTEM_LIBRARY}
${Boost_SYSTEM_LIBRARY}
${Boost_REGEX_LIBRARY})
SetupBoost()

target_link_libraries (lib_interface Boost::filesystem Boost::algorithm)



#------------#
# TEST 1
Expand All @@ -152,14 +150,13 @@ file(COPY tests/speaker-test1.txt tests/speaker-test2.txt
set(LIBINTERFACE_TESTS
tests/balloon_test.cpp)

set(Boost_USE_STATIC_LIBS ON)
find_package(Boost COMPONENTS regex unit_test_framework timer chrono filesystem REQUIRED)
set(Boost_USE_STATIC_LIBS OFF)

add_executable(TEST_lib_interface ${LIBINTERFACE_TESTS})

target_link_libraries (TEST_lib_interface
lib_interface
${Boost_LIBRARIES})
Boost::unit_test_framework)

set_property(TARGET TEST_lib_interface PROPERTY FOLDER "tests")

Expand Down Expand Up @@ -187,7 +184,7 @@ add_executable(TEST_io_lib_interface tests/io_test.cpp )

target_link_libraries (TEST_io_lib_interface
lib_interface
${Boost_LIBRARIES})
Boost::unit_test_framework)


set_property(TARGET TEST_io_lib_interface PROPERTY FOLDER "tests")
Expand Down
2 changes: 1 addition & 1 deletion src/lib_interface/tests/balloon_test.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define BOOST_TEST_MODULE lib_interface balloon tests
#include <boost/test/included/unit_test.hpp>
#include <boost/test/unit_test.hpp>
#include <iostream>
#include <input_output/directivity/directivityParser.h>
#include <Core/mathlib.h>
Expand Down
2 changes: 1 addition & 1 deletion src/lib_interface/tests/io_test.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define BOOST_TEST_MODULE lib_interface modelio tests
#include <boost/test/included/unit_test.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/filesystem/operations.hpp>
#include <iostream>
#include <input_output/bin.h>
Expand Down
1 change: 0 additions & 1 deletion src/preprocess/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ set(PREPROCESS_SOURCE_FILES
# DEPENDENCY & EXECUTABLE (OR LIB)
#---------------------------------------#

find_package(Boost COMPONENTS system filesystem regex REQUIRED)
link_directories( ${Boost_LIBRARY_DIRS} )

# Set Properties->General->Configuration Type to Application
Expand Down
2 changes: 1 addition & 1 deletion src/python_bindings/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ SET(CMAKE_SWIG_FLAGS "")
SET_SOURCE_FILES_PROPERTIES(libsimpa.i PROPERTIES CPLUSPLUS ON)

set(Boost_USE_STATIC_LIBS OFF)
find_package(Boost COMPONENTS system filesystem regex REQUIRED)

link_directories( ${Boost_LIBRARY_DIRS})

IF (${CMAKE_VERSION} VERSION_LESS "3.8.0")
Expand Down
22 changes: 3 additions & 19 deletions src/spps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ include_directories (./ "${CMAKE_SOURCE_DIR}/src/lib_interface" "${CMAKE_CURRENT
set(CMAKE_INSTALL_MFC_LIBRARIES TRUE)
set(CMAKE_INSTALL_UCRT_LIBRARIES TRUE )
include( InstallRequiredSystemLibraries )
message(STATUS " Boost path - $ENV{BOOST_INCLUDEDIR}")
message(STATUS " Boost lib path - $ENV{BOOST_LIBRARYDIR}")

#--------------#
# SOURCES
Expand Down Expand Up @@ -54,18 +52,6 @@ source_group("" FILES ${SPPS_SOURCES} $(SPPS_MAIN_SOURCES))
# DEPENDENCY & EXECUTABLE (OR LIB)
#---------------------------------------#

set(Boost_USE_STATIC_LIBS OFF)

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
find_package(Boost REQUIRED COMPONENTS system random filesystem regex)
else()
find_package (Threads)
find_package(Boost REQUIRED COMPONENTS system random filesystem regex thread chrono date_time)
endif()

link_directories( ${Boost_LIBRARY_DIRS} )
include_directories( ${Boost_INCLUDE_DIRS} )

# Check for clock_gettime function
if (CMAKE_SYSTEM_NAME EQUAL "LINUX")
include(CheckLibraryExists)
Expand All @@ -92,7 +78,7 @@ set_property(TARGET spps PROPERTY FOLDER "executables")


# Properties->Linker->Input->Additional Dependencies
target_link_libraries (spps lib_interface ${Boost_LIBRARIES})
target_link_libraries (spps lib_interface Boost::random Boost::thread)


if(CMAKE_BUILD_TYPE STREQUAL "Debug")
Expand Down Expand Up @@ -155,9 +141,6 @@ file(COPY
# Test executable and folder
set(SPPS_TESTS
tests/spps_core_test.cpp)

set(Boost_USE_STATIC_LIBS ON)
find_package(Boost COMPONENTS filesystem regex unit_test_framework timer chrono REQUIRED)

add_executable(TEST_spps ${SPPS_TESTS}
${DATA_MANAGER_SOURCES}
Expand All @@ -167,7 +150,8 @@ add_executable(TEST_spps ${SPPS_TESTS}

target_link_libraries (TEST_spps
lib_interface
${Boost_LIBRARIES})
Boost::unit_test_framework
Boost::random)
set_property(TARGET TEST_spps PROPERTY FOLDER "tests")

# Add to test suite
Expand Down

0 comments on commit bc12ae8

Please sign in to comment.