Skip to content

Commit

Permalink
Merge pull request #630 from jorisv/topic/cmake_improve
Browse files Browse the repository at this point in the history
Improve CMake
  • Loading branch information
jorisv authored Nov 25, 2024
2 parents 88df2d7 + 3859305 commit 50221d8
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 21 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/conda/environment_macos_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ dependencies:
- octomap
- assimp
- numpy
- boost
- libboost-devel
- libboost-python-devel
- eigenpy
- python
- doxygen<1.9.8|>=1.11
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/conda/environment_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ dependencies:
- octomap
- assimp
- numpy
- boost
- libboost-devel
- libboost-python-devel
- eigenpy
- python
- doxygen<1.9.8|>=1.11
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/windows-conda-clang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,15 @@ jobs:
if errorlevel 1 exit 1
:: Build and Install
cmake --build . --config Release --target install
cmake --build . --config Release --target all
if errorlevel 1 exit 1
:: Testing
ctest --output-on-failure -C Release
if errorlevel 1 exit 1
:: Test Python import
cd ..
python -c "import coal"
cmake -E env PYTHONPATH=%cd%\python python -c "import coal"
if errorlevel 1 exit 1
check:
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/windows-conda-v142.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,15 @@ jobs:
if errorlevel 1 exit 1
:: Build and Install
cmake --build . --config Release --target install
cmake --build . --config Release --target all
if errorlevel 1 exit 1
:: Testing
ctest --output-on-failure -C Release
if errorlevel 1 exit 1
:: Test Python import
cd ..
python -c "import coal"
cmake -E env PYTHONPATH=%cd%\python python -c "import coal"
if errorlevel 1 exit 1
check:
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [Unreleased]

### Fixed
- Remove CMake CMP0167 warnings ([#630](https://github.com/coal-library/coal/pull/630))
- Allow to run test in the build directory on Windows ([#630](https://github.com/coal-library/coal/pull/630))

## [3.0.0] - 2024-11-20

### Added
Expand Down
35 changes: 22 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,18 @@ else()
endif()
endif()

# Use BoostConfig module distributed by boost library instead of using FindBoost module distributed
# by CMake.
# There is one unresolved issue with FindBoost and clang-cl so we deactivate it in this case.
IF(NOT WIN32 OR NOT ${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
IF(POLICY CMP0167)
CMAKE_POLICY(SET CMP0167 NEW)
# Set a default value to this policy to avoid issue with find_dependency
# macro redefinition with different policy in some modules.
SET(CMAKE_POLICY_DEFAULT_CMP0167 NEW)
ENDIF()
ENDIF()

include("${JRL_CMAKE_MODULES}/boost.cmake")
include("${JRL_CMAKE_MODULES}/python.cmake")
include("${JRL_CMAKE_MODULES}/hpp.cmake")
Expand All @@ -101,6 +113,16 @@ SET(CMAKE_MODULE_PATH
${JRL_CMAKE_MODULES}/find-external/assimp/
${CMAKE_MODULE_PATH})

FUNCTION(set_standard_output_directory target)
SET_TARGET_PROPERTIES(
${target}
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin
LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib
ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib
)
ENDFUNCTION()

set_default_cmake_build_type("RelWithDebInfo")

# If needed, fix CMake policy for APPLE systems
Expand All @@ -112,19 +134,6 @@ PROJECT(${PROJECT_NAME} ${PROJECT_ARGS})
OPTION(BUILD_PYTHON_INTERFACE "Build the python bindings" ON)
CMAKE_DEPENDENT_OPTION(GENERATE_PYTHON_STUBS "Generate the Python stubs associated to the Python library" OFF BUILD_PYTHON_INTERFACE OFF)

#IF(WIN32)
# # Set default Windows build paths
# SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY
# ${PROJECT_BINARY_DIR}/Bin
# CACHE PATH "Single directory for all libraries")
# SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY
# ${PROJECT_BINARY_DIR}/Bin
# CACHE PATH "Single directory for all executables")
# SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY
# ${PROJECT_BINARY_DIR}/Bin
# CACHE PATH "Sing$le directory for all archives")
#ENDIF(WIN32)

ADD_PROJECT_DEPENDENCY(Eigen3 REQUIRED PKG_CONFIG_REQUIRES "eigen3 >= 3.0.0")

if(BUILD_PYTHON_INTERFACE)
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ add_library(${LIBRARY_NAME}
${${LIBRARY_NAME}_SOURCES}
)
add_library(${LIBRARY_NAME}::${LIBRARY_NAME} ALIAS ${LIBRARY_NAME})
SET_STANDARD_OUTPUT_DIRECTORY(${LIBRARY_NAME})

if(COAL_BACKWARD_COMPATIBILITY_WITH_HPP_FCL)
add_library(hpp-fcl ALIAS ${LIBRARY_NAME})
Expand Down
3 changes: 3 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ config_files(fcl_resources/config.h)
function(add_coal_test test_name source)
set(target_name ${PROJECT_NAME}-${test_name})
ADD_UNIT_TEST(${target_name} ${source})
SET_STANDARD_OUTPUT_DIRECTORY(${target_name})
target_link_libraries(${target_name}
PUBLIC
${LIBRARY_NAME}
Expand All @@ -24,6 +25,7 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR})

set(utility_target ${PROJECT_NAME}-utility)
add_library(${utility_target} STATIC utility.cpp)
SET_STANDARD_OUTPUT_DIRECTORY(${utility_target})
target_link_libraries(${utility_target} PUBLIC ${PROJECT_NAME})

add_coal_test(math math.cpp)
Expand Down Expand Up @@ -77,6 +79,7 @@ add_coal_test(broadphase_collision_2 broadphase_collision_2.cpp)
## Benchmark
set(test_benchmark_target ${PROJECT_NAME}-test-benchmark)
add_executable(${test_benchmark_target} benchmark.cpp)
SET_STANDARD_OUTPUT_DIRECTORY(${test_benchmark_target})
target_link_libraries(${test_benchmark_target}
PUBLIC
${utility_target}
Expand Down

0 comments on commit 50221d8

Please sign in to comment.