From ad86c1842091800eeff5fdcb32e766ac2338e50c Mon Sep 17 00:00:00 2001 From: ManifoldFR Date: Wed, 23 Oct 2024 11:40:58 +0200 Subject: [PATCH] pre-commit run -a --- .docs/examples/minimal-with-packages.cmake | 5 +- CMakeLists.txt | 207 +++--- _unittests/catkin/CMakeLists.txt | 10 +- _unittests/cpp/CMakeLists.txt | 10 +- _unittests/test_pkg-config.cmake | 12 +- apple.cmake | 8 +- base.cmake | 112 +-- boost.cmake | 175 +++-- compiler.cmake | 98 +-- coverage.cmake | 27 +- cpack.cmake | 35 +- createshexe.cmake | 6 +- cxx-standard.cmake | 109 ++- cxx11.cmake | 3 +- cython/cython.cmake | 481 ++++++++----- debian.cmake | 52 +- distcheck.cmake | 36 +- doxygen.cmake | 199 ++++-- eigen.cmake | 18 +- find-external/Accelerate/FindAccelerate.cmake | 19 +- find-external/CDD/FindCDD.cmake | 23 +- find-external/CHOLMOD/FindCHOLMOD.cmake | 96 ++- find-external/CLP/FindCLP.cmake | 25 +- find-external/CoinUtils/FindCoinUtils.cmake | 32 +- find-external/CppAD/Findcppad.cmake | 26 +- find-external/CppAD/Findcppadcg.cmake | 31 +- find-external/GMP/FindGMP.cmake | 29 +- find-external/Ipopt/FindIpopt.cmake | 27 +- find-external/Julia/FindJulia.cmake | 82 ++- find-external/MPFR/FindMPFR.cmake | 77 ++- find-external/OpenMP/FindOpenMP.cmake | 647 +++++++++++------- find-external/OpenRTM/FindOpenRTM.cmake | 71 +- find-external/Qhull/FindQhull.cmake | 98 ++- find-external/Simde/FindSimde.cmake | 24 +- find-external/TinyXML/FindTinyXML.cmake | 16 +- find-external/TinyXML/FindTinyXML2.cmake | 44 +- find-external/assimp/Findassimp.cmake | 77 ++- find-external/glpk/Findglpk.cmake | 37 +- find-external/qpOASES/FindqpOASES.cmake | 36 +- geometric-tools.cmake | 45 +- gtest.cmake | 28 +- hpp.cmake | 8 +- ide.cmake | 26 +- idl.cmake | 87 ++- idlrtc.cmake | 43 +- image/visp.cmake | 12 +- install-data.cmake | 3 +- julia.cmake | 21 +- kineo.cmake | 49 +- lapack.cmake | 3 +- logging.cmake | 103 ++- man.cmake | 17 +- metapodfromurdf.cmake | 13 +- modernize-links.cmake | 31 +- msvc-specific.cmake | 64 +- openhrp.cmake | 8 +- openhrpcontroller.cmake | 33 +- openrtm.cmake | 15 +- package-config.cmake | 204 ++++-- pkg-config.cmake | 614 ++++++++++------- portability.cmake | 17 +- post-project.cmake | 9 +- pthread.cmake | 11 +- python-helpers.cmake | 29 +- python.cmake | 241 ++++--- qhull.cmake | 90 ++- relpath.cmake | 8 +- ros.cmake | 52 +- ros2.cmake | 23 +- sdformat.cmake | 15 +- shared-library.cmake | 11 +- sphinx.cmake | 67 +- stubs.cmake | 60 +- swig.cmake | 31 +- test.cmake | 105 +-- tracy.cmake | 31 +- uninstall.cmake | 50 +- version-script.cmake | 25 +- version.cmake | 80 ++- xacro.cmake | 31 +- 80 files changed, 3446 insertions(+), 2087 deletions(-) diff --git a/.docs/examples/minimal-with-packages.cmake b/.docs/examples/minimal-with-packages.cmake index f2d419c69..cd6953a2e 100644 --- a/.docs/examples/minimal-with-packages.cmake +++ b/.docs/examples/minimal-with-packages.cmake @@ -22,7 +22,4 @@ add_project_dependency(Boost 1.50 REQUIRED COMPONENT timer) add_library(myLibrary ${MY_SOURCES}) target_link_libraries(myLibrary MyDependency::MyAwesomeLib Boost::timer) -install( - TARGETS myLibrary - EXPORT ${TARGETS_EXPORT_NAME} - DESTINATION lib) +install(TARGETS myLibrary EXPORT ${TARGETS_EXPORT_NAME} DESTINATION lib) diff --git a/CMakeLists.txt b/CMakeLists.txt index cd19fafe7..b1075c458 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,8 @@ project( ${PROJECT_NAME} DESCRIPTION ${PROJECT_DESCRIPTION} LANGUAGES CXX - VERSION 0.0.0) + VERSION 0.0.0 +) if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) # Generate CMake exports @@ -20,111 +21,117 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) # Add a dummy library with a useful INTERFACE_INCLUDE_DIRECTORIES add_library(${PROJECT_NAME} INTERFACE) set(INSTALL_DIR "${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}") - target_include_directories(${PROJECT_NAME} - INTERFACE $) + target_include_directories( + ${PROJECT_NAME} + INTERFACE $ + ) # find . -maxdepth 1 -type d ! -path './.*' | sort install( - DIRECTORY ./boost - ./cython - ./doxygen - ./dynamic_graph - ./find-external - ./github - ./gtest - ./hpp - ./image - ./sphinx - ./stubgen - ./_unittests - DESTINATION ${INSTALL_DIR}) + DIRECTORY + ./boost + ./cython + ./doxygen + ./dynamic_graph + ./find-external + ./github + ./gtest + ./hpp + ./image + ./sphinx + ./stubgen + ./_unittests + DESTINATION ${INSTALL_DIR} + ) # find . -maxdepth 1 -type f ! -path './.*' | sort install( - FILES ./announce-gen - ./apple.cmake - ./base.cmake - ./boost.cmake - ./catkin.cmake - ./CMakeLists.txt - ./cmake_reinstall.cmake.in - ./cmake_uninstall.cmake.in - ./compiler.cmake - ./componentConfig.cmake.in - ./Config.cmake.in - ./config.h.cmake - ./config.hh.cmake - ./coverage.cmake - ./cpack.cmake - ./createshexe.cmake - ./cxx11.cmake - ./cxx-standard.cmake - ./debian.cmake - ./deprecated.hh.cmake - ./distcheck.cmake - ./dist.cmake - ./doxygen.cmake - ./eigen.cmake - ./filefilter.txt - ./fix-license.sh - ./geometric-tools.cmake - ./git-archive-all.py - ./git-archive-all.sh - ./gitlog-to-changelog - ./GNUInstallDirs.cmake - ./gtest.cmake - ./header.cmake - ./hpp.cmake - ./ide.cmake - ./idl.cmake - ./idlrtc.cmake - ./install-data.cmake - ./julia.cmake - ./kineo.cmake - ./lapack.cmake - ./LICENSE - ./logging.cmake - ./man.cmake - ./memorycheck_unit_test.cmake.in - ./metapodfromurdf.cmake - ./modernize-links.cmake - ./msvc-specific.cmake - ./msvc.vcxproj.user.in - ./openhrp.cmake - ./openhrpcontroller.cmake - ./openrtm.cmake - ./oscheck.cmake - ./package-config.cmake - ./pkg-config.cmake - ./pkg-config.pc.cmake - ./portability.cmake - ./post-project.cmake - ./pthread.cmake - ./pyproject.py - ./python.cmake - ./python-helpers.cmake - ./qhull.cmake - ./README.md - ./release.cmake - ./relpath.cmake - ./ros.cmake - ./ros2.cmake - ./sdformat.cmake - ./setup.cfg - ./shared-library.cmake - ./sphinx.cmake - ./stubs.cmake - ./swig.cmake - ./test.cmake - ./tracy.cmake - ./tracy.hh.cmake - ./uninstall.cmake - ./version.cmake - ./version-script.cmake - ./version-script-test.lds - ./warning.hh.cmake - ./xacro.cmake - DESTINATION ${INSTALL_DIR}) + FILES + ./announce-gen + ./apple.cmake + ./base.cmake + ./boost.cmake + ./catkin.cmake + ./CMakeLists.txt + ./cmake_reinstall.cmake.in + ./cmake_uninstall.cmake.in + ./compiler.cmake + ./componentConfig.cmake.in + ./Config.cmake.in + ./config.h.cmake + ./config.hh.cmake + ./coverage.cmake + ./cpack.cmake + ./createshexe.cmake + ./cxx11.cmake + ./cxx-standard.cmake + ./debian.cmake + ./deprecated.hh.cmake + ./distcheck.cmake + ./dist.cmake + ./doxygen.cmake + ./eigen.cmake + ./filefilter.txt + ./fix-license.sh + ./geometric-tools.cmake + ./git-archive-all.py + ./git-archive-all.sh + ./gitlog-to-changelog + ./GNUInstallDirs.cmake + ./gtest.cmake + ./header.cmake + ./hpp.cmake + ./ide.cmake + ./idl.cmake + ./idlrtc.cmake + ./install-data.cmake + ./julia.cmake + ./kineo.cmake + ./lapack.cmake + ./LICENSE + ./logging.cmake + ./man.cmake + ./memorycheck_unit_test.cmake.in + ./metapodfromurdf.cmake + ./modernize-links.cmake + ./msvc-specific.cmake + ./msvc.vcxproj.user.in + ./openhrp.cmake + ./openhrpcontroller.cmake + ./openrtm.cmake + ./oscheck.cmake + ./package-config.cmake + ./pkg-config.cmake + ./pkg-config.pc.cmake + ./portability.cmake + ./post-project.cmake + ./pthread.cmake + ./pyproject.py + ./python.cmake + ./python-helpers.cmake + ./qhull.cmake + ./README.md + ./release.cmake + ./relpath.cmake + ./ros.cmake + ./ros2.cmake + ./sdformat.cmake + ./setup.cfg + ./shared-library.cmake + ./sphinx.cmake + ./stubs.cmake + ./swig.cmake + ./test.cmake + ./tracy.cmake + ./tracy.hh.cmake + ./uninstall.cmake + ./version.cmake + ./version-script.cmake + ./version-script-test.lds + ./warning.hh.cmake + ./xacro.cmake + DESTINATION ${INSTALL_DIR} + ) install(TARGETS ${PROJECT_NAME} EXPORT ${TARGETS_EXPORT_NAME}) endif() diff --git a/_unittests/catkin/CMakeLists.txt b/_unittests/catkin/CMakeLists.txt index 5edb11c64..59663841f 100644 --- a/_unittests/catkin/CMakeLists.txt +++ b/_unittests/catkin/CMakeLists.txt @@ -15,11 +15,15 @@ project(${PROJECT_NAME} LANGUAGES CXX) # * Otherwise it is assumed it is created by the project and removed with the # uninstall target -option(FORCE_DOT_CATKIN_CREATION - "Force creation of .catkin file in install destination" OFF) +option( + FORCE_DOT_CATKIN_CREATION + "Force creation of .catkin file in install destination" + OFF +) if(FORCE_DOT_CATKIN_CREATION) install( - CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_INSTALL_PREFIX}/.catkin)" + CODE + "execute_process(COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_INSTALL_PREFIX}/.catkin)" ) endif() diff --git a/_unittests/cpp/CMakeLists.txt b/_unittests/cpp/CMakeLists.txt index 40cd1e4e4..c666e12e9 100644 --- a/_unittests/cpp/CMakeLists.txt +++ b/_unittests/cpp/CMakeLists.txt @@ -16,13 +16,17 @@ set(${PROJECT_NAME}_HEADERS include/jrl_cmakemodule/lib.hh) add_library(jrl_cmakemodule_lib SHARED src/lib.cc) target_include_directories( jrl_cmakemodule_lib - PUBLIC $ - $) + PUBLIC + $ + $ +) install( TARGETS jrl_cmakemodule_lib EXPORT ${TARGETS_EXPORT_NAME} - DESTINATION lib) + DESTINATION + lib +) add_executable(jrl_cmakemodule_main src/main.cc) target_link_libraries(jrl_cmakemodule_main jrl_cmakemodule_lib) diff --git a/_unittests/test_pkg-config.cmake b/_unittests/test_pkg-config.cmake index ca33930bc..1b7fe729a 100644 --- a/_unittests/test_pkg-config.cmake +++ b/_unittests/test_pkg-config.cmake @@ -15,21 +15,24 @@ endmacro() unset_test_vars() _parse_pkg_config_string("my-package > 0.4" PKG_LIB_NAME PKG_PREFIX - PKG_CONFIG_STRING_NOSPACE) + PKG_CONFIG_STRING_NOSPACE +) expect_strequal("my-package" "${PKG_LIB_NAME}") expect_strequal("MY_PACKAGE" "${PKG_PREFIX}") expect_strequal("my-package>0.4" "${PKG_CONFIG_STRING_NOSPACE}") unset_test_vars() _parse_pkg_config_string("my-package >= 0.4" PKG_LIB_NAME PKG_PREFIX - PKG_CONFIG_STRING_NOSPACE) + PKG_CONFIG_STRING_NOSPACE +) expect_strequal("my-package" "${PKG_LIB_NAME}") expect_strequal("MY_PACKAGE" "${PKG_PREFIX}") expect_strequal("my-package>=0.4" "${PKG_CONFIG_STRING_NOSPACE}") unset_test_vars() _parse_pkg_config_string("my-package" PKG_LIB_NAME PKG_PREFIX - PKG_CONFIG_STRING_NOSPACE) + PKG_CONFIG_STRING_NOSPACE +) expect_strequal("my-package" "${PKG_LIB_NAME}") expect_strequal("MY_PACKAGE" "${PKG_PREFIX}") expect_strequal("my-package" "${PKG_CONFIG_STRING_NOSPACE}") @@ -39,7 +42,8 @@ expect_strequal("my-package" "${PKG_CONFIG_STRING_NOSPACE}") # with pkg-config's behavior. unset_test_vars() _parse_pkg_config_string("my-package>=0.4" PKG_LIB_NAME PKG_PREFIX - PKG_CONFIG_STRING_NOSPACE) + PKG_CONFIG_STRING_NOSPACE +) expect_strequal("my-package>=0.4" "${PKG_LIB_NAME}") expect_strequal("MY_PACKAGE__0_4" "${PKG_PREFIX}") expect_strequal("my-package>=0.4" "${PKG_CONFIG_STRING_NOSPACE}") diff --git a/apple.cmake b/apple.cmake index 93ba4c5b6..14235fb68 100644 --- a/apple.cmake +++ b/apple.cmake @@ -25,8 +25,12 @@ macro(APPLY_DEFAULT_APPLE_CONFIGURATION) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") - list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES - "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir) + list( + FIND + CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES + "${CMAKE_INSTALL_PREFIX}/lib" + isSystemDir + ) if("${isSystemDir}" STREQUAL "-1") set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") endif("${isSystemDir}" STREQUAL "-1") diff --git a/base.cmake b/base.cmake index e449882e0..f55016852 100644 --- a/base.cmake +++ b/base.cmake @@ -142,17 +142,13 @@ if(CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 3.10) message( FATAL_ERROR - "JRL-CMakemodules require CMake >= 3.10. Please update your main 'cmake_minimum_required'" + "JRL-CMakemodules require CMake >= 3.10. Please update your main 'cmake_minimum_required'" ) endif() -set(PROJECT_JRL_CMAKE_MODULE_DIR - ${CMAKE_CURRENT_LIST_DIR} - CACHE INTERNAL "") +set(PROJECT_JRL_CMAKE_MODULE_DIR ${CMAKE_CURRENT_LIST_DIR} CACHE INTERNAL "") -set(PROJECT_JRL_CMAKE_BINARY_DIR - ${CMAKE_CURRENT_BINARY_DIR} - CACHE INTERNAL "") +set(PROJECT_JRL_CMAKE_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} CACHE INTERNAL "") if(NOT DEFINED PROJECT_AUTO_RUN_FINALIZE) set(PROJECT_AUTO_RUN_FINALIZE TRUE) @@ -194,14 +190,16 @@ foreach(VARIABLE ${REQUIRED_VARIABLES}) if(NOT DEFINED ${VARIABLE}) message( AUTHOR_WARNING - "Required variable ``${VARIABLE}'' has not been defined, perhaps you are including cmake/base.cmake too early" + "Required variable ``${VARIABLE}'' has not been defined, perhaps you are including cmake/base.cmake too early" ) message( AUTHOR_WARNING - "Check out https://jrl-cmakemodules.readthedocs.io/en/master/pages/base.html#minimal-working-example for an example" + "Check out https://jrl-cmakemodules.readthedocs.io/en/master/pages/base.html#minimal-working-example for an example" ) message( - FATAL_ERROR "Required variable ``${VARIABLE}'' has not been defined.") + FATAL_ERROR + "Required variable ``${VARIABLE}'' has not been defined." + ) endif(NOT DEFINED ${VARIABLE}) endforeach(VARIABLE) @@ -211,11 +209,14 @@ message(STATUS "Configuring \"${PROJECT_NAME}\" (${PROJECT_URL})") if(NOT DEFINED PROJECT_VERSION) version_compute() else() - if(NOT DEFINED PROJECT_VERSION_MAJOR - AND NOT DEFINED PROJECT_VERSION_MINOR - AND NOT DEFINED PROJECT_VERSION_PATCH) + if( + NOT DEFINED PROJECT_VERSION_MAJOR + AND NOT DEFINED PROJECT_VERSION_MINOR + AND NOT DEFINED PROJECT_VERSION_PATCH + ) split_version_number(${PROJECT_VERSION} PROJECT_VERSION_MAJOR - PROJECT_VERSION_MINOR PROJECT_VERSION_PATCH) + PROJECT_VERSION_MINOR PROJECT_VERSION_PATCH + ) endif() endif() set(SAVED_PROJECT_VERSION "${PROJECT_VERSION}") @@ -227,18 +228,23 @@ if(PROJECT_VERSION MATCHES UNKNOWN) set(PROJECT_VERSION_FULL "") else(PROJECT_VERSION MATCHES UNKNOWN) if(PROJECT_VERSION_PATCH) - set(PROJECT_VERSION_FULL - "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}" + set( + PROJECT_VERSION_FULL + "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}" ) else(PROJECT_VERSION_PATCH) - set(PROJECT_VERSION_FULL - "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}") + set( + PROJECT_VERSION_FULL + "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}" + ) endif(PROJECT_VERSION_PATCH) endif(PROJECT_VERSION MATCHES UNKNOWN) # Set a script to run after project called -set(CMAKE_PROJECT_${PROJECT_NAME}_INCLUDE - "${CMAKE_CURRENT_LIST_DIR}/post-project.cmake") +set( + CMAKE_PROJECT_${PROJECT_NAME}_INCLUDE + "${CMAKE_CURRENT_LIST_DIR}/post-project.cmake" +) # Set a hook to finalize the setup, CMake will set CMAKE_CURRENT_LIST_DIR to "" # at the end Based off @@ -248,8 +254,10 @@ if(PROJECT_AUTO_RUN_FINALIZE) function(SETUP_PROJECT_FINALIZE_HOOK VARIABLE ACCESS) if("${${VARIABLE}}" STREQUAL "") set(CMAKE_CURRENT_LIST_DIR ${PROJECT_JRL_CMAKE_MODULE_DIR}) - set(JRL_CMAKEMODULE_LOGGING_FILENAME - "${PROJECT_JRL_CMAKE_BINARY_DIR}/config.log") + set( + JRL_CMAKEMODULE_LOGGING_FILENAME + "${PROJECT_JRL_CMAKE_BINARY_DIR}/config.log" + ) setup_project_finalize() set(CMAKE_CURRENT_LIST_DIR "") # restore value set(JRL_CMAKEMODULE_LOGGING_FILENAME "") # restore value @@ -275,10 +283,7 @@ macro(_ADD_TO_LIST LIST VALUE SEPARATOR) set(${LIST} "${${LIST}}${SEPARATOR} ${VALUE}") endif(NOT "${VALUE}" STREQUAL "") endif("${${LIST}}" STREQUAL "") -endmacro( - _ADD_TO_LIST - LIST - VALUE) +endmacro(_ADD_TO_LIST LIST VALUE) # _ADD_TO_LIST_IF_NOT_PRESENT LIST VALUE # ----------------------- @@ -292,10 +297,7 @@ macro(_ADD_TO_LIST_IF_NOT_PRESENT LIST VALUE) if(NOT "${VALUE}" IN_LIST ${LIST}) list(APPEND ${LIST} "${VALUE}") endif() -endmacro( - _ADD_TO_LIST_IF_NOT_PRESENT - LIST - VALUE) +endmacro(_ADD_TO_LIST_IF_NOT_PRESENT LIST VALUE) # _CONCATENATE_ARGUMENTS # ---------------------- @@ -380,9 +382,15 @@ macro(COMPUTE_PROJECT_ARGS _project_VARIABLE) set(_project_LANGUAGES "CXX") endif() - set(${_project_VARIABLE} - VERSION ${PROJECT_VERSION_FULL} LANGUAGES ${_project_LANGUAGES} - DESCRIPTION ${PROJECT_DESCRIPTION}) + set( + ${_project_VARIABLE} + VERSION + ${PROJECT_VERSION_FULL} + LANGUAGES + ${_project_LANGUAGES} + DESCRIPTION + ${PROJECT_DESCRIPTION} + ) endmacro(COMPUTE_PROJECT_ARGS) # .rst: .. ifmode:: user @@ -396,23 +404,37 @@ endmacro(COMPUTE_PROJECT_ARGS) macro(SET_DEFAULT_CMAKE_BUILD_TYPE build_type) string(TOLOWER "${build_type}" build_type_lower) - if(NOT "${build_type_lower}" MATCHES - "(debug)|(release)|(relwithdebinfo)|(minsizerel)") + if( + NOT + "${build_type_lower}" + MATCHES + "(debug)|(release)|(relwithdebinfo)|(minsizerel)" + ) message( FATAL_ERROR - "${build_type} value does not match with Debug, Release, RelWithDebInfo or MinSizeRel" + "${build_type} value does not match with Debug, Release, RelWithDebInfo or MinSizeRel" ) endif() - if(NOT CMAKE_BUILD_TYPE - AND NOT CMAKE_CONFIGURATION_TYPES - AND NOT DEFINED ENV{CMAKE_BUILD_TYPE}) - set(CMAKE_BUILD_TYPE - ${build_type} - CACHE STRING "Choose the build type value." FORCE) - set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" - "RelWithDebInfo" "MinSizeRel") + if( + NOT CMAKE_BUILD_TYPE + AND NOT CMAKE_CONFIGURATION_TYPES + AND NOT DEFINED ENV{CMAKE_BUILD_TYPE} + ) + set( + CMAKE_BUILD_TYPE + ${build_type} + CACHE STRING + "Choose the build type value." + FORCE + ) + set_property( + CACHE CMAKE_BUILD_TYPE + PROPERTY STRINGS "Debug" "Release" "RelWithDebInfo" "MinSizeRel" + ) message( - STATUS "CMAKE_BUILD_TYPE has automatically been set to ${build_type}") + STATUS + "CMAKE_BUILD_TYPE has automatically been set to ${build_type}" + ) endif() endmacro(SET_DEFAULT_CMAKE_BUILD_TYPE) diff --git a/boost.cmake b/boost.cmake index 8a5a4b7a5..29cfb398e 100644 --- a/boost.cmake +++ b/boost.cmake @@ -21,27 +21,24 @@ # FALSE otherwise. This function is for internal use only. # function(SEARCH_FOR_BOOST_COMPONENT boost_python_name found) - set(${found} - FALSE - PARENT_SCOPE) - find_package(Boost ${BOOST_REQUIRED} QUIET - OPTIONAL_COMPONENTS ${boost_python_name}) + set(${found} FALSE PARENT_SCOPE) + find_package( + Boost + ${BOOST_REQUIRED} + QUIET + OPTIONAL_COMPONENTS ${boost_python_name} + ) string(TOUPPER ${boost_python_name} boost_python_name_UPPER) if(Boost_${boost_python_name_UPPER}_FOUND) - set(${found} - TRUE - PARENT_SCOPE) + set(${found} TRUE PARENT_SCOPE) endif() -endfunction( - SEARCH_FOR_BOOST_COMPONENT - boost_python_name - found) +endfunction(SEARCH_FOR_BOOST_COMPONENT boost_python_name found) if(CMAKE_VERSION VERSION_LESS "3.12") set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/boost ${CMAKE_MODULE_PATH}) message( STATUS - "CMake versions older than 3.12 may warn when looking to Boost components. Custom macros are used to find it." + "CMake versions older than 3.12 may warn when looking to Boost components. Custom macros are used to find it." ) endif(CMAKE_VERSION VERSION_LESS "3.12") @@ -85,12 +82,16 @@ endmacro(EXPORT_BOOST_DEFAULT_OPTIONS) # macro(SEARCH_FOR_BOOST_PYTHON) - set(options REQUIRED) set(oneValueArgs NAME) set(multiValueArgs) - cmake_parse_arguments(SEARCH_FOR_BOOST_PYTHON_ARGS "${options}" - "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + cmake_parse_arguments( + SEARCH_FOR_BOOST_PYTHON_ARGS + "${options}" + "${oneValueArgs}" + "${multiValueArgs}" + ${ARGN} + ) cmake_parse_arguments(_BOOST_PYTHON_REQUIRED "REQUIRED" "" "" ${ARGN}) set(BOOST_PYTHON_NAME "python") set(BOOST_PYTHON_REQUIRED "") @@ -103,7 +104,7 @@ macro(SEARCH_FOR_BOOST_PYTHON) if(NOT PYTHON_EXECUTABLE) message( FATAL_ERROR - "Python has not been found. You should first call FindPython before calling SEARCH_FOR_BOOST_PYTHON macro." + "Python has not been found. You should first call FindPython before calling SEARCH_FOR_BOOST_PYTHON macro." ) endif(NOT PYTHON_EXECUTABLE) @@ -111,10 +112,12 @@ macro(SEARCH_FOR_BOOST_PYTHON) set(BOOST_PYTHON_NAME ${SEARCH_FOR_BOOST_PYTHON_ARGS_NAME}) else() # Test: pythonX, pythonXY and python-pyXY - set(BOOST_PYTHON_COMPONENT_LIST - "python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}" - "python${PYTHON_VERSION_MAJOR}" - "python-py${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}") + set( + BOOST_PYTHON_COMPONENT_LIST + "python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}" + "python${PYTHON_VERSION_MAJOR}" + "python-py${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}" + ) set(BOOST_PYTHON_FOUND FALSE) foreach(BOOST_PYTHON_COMPONENT ${BOOST_PYTHON_COMPONENT_LIST}) search_for_boost_component(${BOOST_PYTHON_COMPONENT} BOOST_PYTHON_FOUND) @@ -129,24 +132,30 @@ macro(SEARCH_FOR_BOOST_PYTHON) if(NOT BOOST_PYTHON_FOUND) message( WARNING - "Impossible to check Boost.Python version. Trying with 'python'.") + "Impossible to check Boost.Python version. Trying with 'python'." + ) endif(NOT BOOST_PYTHON_FOUND) - endif() if(PYTHON_EXPORT_DEPENDENCY) install_jrl_cmakemodules_dir("boost") install_jrl_cmakemodules_file("boost.cmake") - set(PYTHON_EXPORT_DEPENDENCY_MACROS - "${PYTHON_EXPORT_DEPENDENCY_MACROS}\nSEARCH_FOR_BOOST_PYTHON(${BOOST_PYTHON_REQUIRED} NAME ${BOOST_PYTHON_NAME})" + set( + PYTHON_EXPORT_DEPENDENCY_MACROS + "${PYTHON_EXPORT_DEPENDENCY_MACROS}\nSEARCH_FOR_BOOST_PYTHON(${BOOST_PYTHON_REQUIRED} NAME ${BOOST_PYTHON_NAME})" ) endif() find_package(Boost ${BOOST_PYTHON_REQUIRED} COMPONENTS ${BOOST_PYTHON_NAME}) string(TOUPPER ${BOOST_PYTHON_NAME} UPPERCOMPONENT) - list(APPEND LOGGING_WATCHED_VARIABLES Boost_${UPPERCOMPONENT}_FOUND - Boost_${UPPERCOMPONENT}_LIBRARY Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG - Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE) + list( + APPEND + LOGGING_WATCHED_VARIABLES + Boost_${UPPERCOMPONENT}_FOUND + Boost_${UPPERCOMPONENT}_LIBRARY + Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG + Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE + ) set(Boost_PYTHON_LIBRARY ${Boost_${UPPERCOMPONENT}_LIBRARY}) list(APPEND Boost_PYTHON_LIBRARIES ${Boost_PYTHON_LIBRARY}) @@ -181,7 +190,7 @@ endmacro(SEARCH_FOR_BOOST_PYTHON) macro(SEARCH_FOR_BOOST) message( AUTHOR_WARNING - "SEARCH_FOR_BOOST is deprecated. Please use find_package() / SEARCH_FOR_BOOST_PYTHON()" + "SEARCH_FOR_BOOST is deprecated. Please use find_package() / SEARCH_FOR_BOOST_PYTHON()" ) set(Boost_USE_STATIC_LIBS OFF) set(Boost_USE_MULTITHREADED ON) @@ -189,16 +198,26 @@ macro(SEARCH_FOR_BOOST) # First try to find Boost to get the version find_package(Boost ${BOOST_REQUIRED}) string(REPLACE "_" "." Boost_SHORT_VERSION ${Boost_LIB_VERSION}) - if("${Boost_SHORT_VERSION}" VERSION_GREATER "1.70" OR "${Boost_SHORT_VERSION}" - VERSION_EQUAL "1.70") + if( + "${Boost_SHORT_VERSION}" VERSION_GREATER "1.70" + OR "${Boost_SHORT_VERSION}" VERSION_EQUAL "1.70" + ) set(BUILD_SHARED_LIBS ON) set(Boost_NO_BOOST_CMAKE ON) - endif("${Boost_SHORT_VERSION}" VERSION_GREATER "1.70" - OR "${Boost_SHORT_VERSION}" VERSION_EQUAL "1.70") + endif( + "${Boost_SHORT_VERSION}" VERSION_GREATER "1.70" + OR "${Boost_SHORT_VERSION}" VERSION_EQUAL "1.70" + ) if(NOT DEFINED BOOST_COMPONENTS) - set(BOOST_COMPONENTS filesystem system thread program_options - unit_test_framework) + set( + BOOST_COMPONENTS + filesystem + system + thread + program_options + unit_test_framework + ) endif(NOT DEFINED BOOST_COMPONENTS) # Check if python is in the list and adjust the version according to the @@ -211,17 +230,28 @@ macro(SEARCH_FOR_BOOST) endif(${PYTHON_IN_BOOST_COMPONENTS} GREATER -1) # Make Boost component exportable - list(INSERT _PACKAGE_CONFIG_DEPENDENCIES_FIND_PACKAGE 0 - "SET(Boost_USE_STATIC_LIBS OFF);SET(Boost_USE_MULTITHREADED ON)") - list(INSERT _PACKAGE_CONFIG_DEPENDENCIES_FIND_DEPENDENCY 0 - "SET(Boost_USE_STATIC_LIBS OFF);SET(Boost_USE_MULTITHREADED ON)") + list( + INSERT + _PACKAGE_CONFIG_DEPENDENCIES_FIND_PACKAGE + 0 + "SET(Boost_USE_STATIC_LIBS OFF);SET(Boost_USE_MULTITHREADED ON)" + ) + list( + INSERT + _PACKAGE_CONFIG_DEPENDENCIES_FIND_DEPENDENCY + 0 + "SET(Boost_USE_STATIC_LIBS OFF);SET(Boost_USE_MULTITHREADED ON)" + ) add_project_dependency(Boost ${BOOST_REQUIRED} COMPONENTS ${BOOST_COMPONENTS} - REQUIRED) + REQUIRED + ) if(NOT Boost_FOUND) message( - FATAL_ERROR "Failed to detect Boost with the following components:\n" - ${COMPONENTS}) + FATAL_ERROR + "Failed to detect Boost with the following components:\n" + ${COMPONENTS} + ) endif(NOT Boost_FOUND) pkg_config_append_cflags("-I${Boost_INCLUDE_DIR}") @@ -248,12 +278,18 @@ macro(SEARCH_FOR_BOOST) Boost_MAJOR_VERSION Boost_MINOR_VERSION Boost_SUBMINOR_VERSION - Boost_LIB_DIAGNOSTIC_DEFINITIONS) + Boost_LIB_DIAGNOSTIC_DEFINITIONS + ) foreach(COMPONENT ${BOOST_COMPONENTS}) string(TOUPPER ${COMPONENT} UPPERCOMPONENT) - list(APPEND LOGGING_WATCHED_VARIABLES Boost_${UPPERCOMPONENT}_FOUND - Boost_${UPPERCOMPONENT}_LIBRARY Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG - Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE) + list( + APPEND + LOGGING_WATCHED_VARIABLES + Boost_${UPPERCOMPONENT}_FOUND + Boost_${UPPERCOMPONENT}_LIBRARY + Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG + Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE + ) endforeach() # On darwin systems, we must link againt boost_python with unresolved symbols. @@ -286,34 +322,49 @@ macro(TARGET_LINK_BOOST_PYTHON target) if(TARGET Boost::python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}) target_link_libraries( - ${target} ${PUBLIC_KEYWORD} - Boost::python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}) - + ${target} + ${PUBLIC_KEYWORD} + Boost::python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR} + ) else() - if(APPLE) get_target_property(TARGET_TYPE ${target} TYPE) if(${TARGET_TYPE} MATCHES EXECUTABLE) - target_link_libraries(${target} ${PUBLIC_KEYWORD} - ${Boost_PYTHON_LIBRARY}) + target_link_libraries( + ${target} + ${PUBLIC_KEYWORD} + ${Boost_PYTHON_LIBRARY} + ) else(${TARGET_TYPE} MATCHES EXECUTABLE) target_link_libraries( - ${target} ${PUBLIC_KEYWORD} - -Wl,-undefined,dynamic_lookup,${Boost_PYTHON_LIBRARIES}) + ${target} + ${PUBLIC_KEYWORD} + -Wl,-undefined,dynamic_lookup,${Boost_PYTHON_LIBRARIES} + ) endif(${TARGET_TYPE} MATCHES EXECUTABLE) - target_include_directories(${target} SYSTEM ${PUBLIC_KEYWORD} - ${Boost_INCLUDE_DIR}) + target_include_directories( + ${target} + SYSTEM + ${PUBLIC_KEYWORD} + ${Boost_INCLUDE_DIR} + ) else(APPLE) - - target_link_libraries(${target} ${PUBLIC_KEYWORD} - ${Boost_PYTHON_LIBRARIES}) - target_include_directories(${target} SYSTEM ${PUBLIC_KEYWORD} - ${Boost_INCLUDE_DIR} ${PYTHON_INCLUDE_DIR}) + target_link_libraries( + ${target} + ${PUBLIC_KEYWORD} + ${Boost_PYTHON_LIBRARIES} + ) + target_include_directories( + ${target} + SYSTEM + ${PUBLIC_KEYWORD} + ${Boost_INCLUDE_DIR} + ${PYTHON_INCLUDE_DIR} + ) endif(APPLE) list(APPEND LOGGING_WATCHED_VARIABLES Boost_PYTHON_LIBRARIES) - endif() endmacro(TARGET_LINK_BOOST_PYTHON) diff --git a/compiler.cmake b/compiler.cmake index 48c349f2b..afe75cf5c 100644 --- a/compiler.cmake +++ b/compiler.cmake @@ -19,16 +19,18 @@ macro(_SETUP_PROJECT_WARNINGS) # -Wmissing-declarations is disabled for now as older GCC version does not # support it but CMake doest not check for the flag acceptance correctly. - set(GNU_FLAGS - -pedantic - -Wno-long-long - -Wall - -Wextra - -Wcast-align - -Wcast-qual - -Wformat - -Wwrite-strings - -Wconversion) + set( + GNU_FLAGS + -pedantic + -Wno-long-long + -Wall + -Wextra + -Wcast-align + -Wcast-qual + -Wformat + -Wwrite-strings + -Wconversion + ) if(NOT DEFINED CXX_DISABLE_WERROR) list(APPEND GNU_FLAGS -Werror) endif(NOT DEFINED CXX_DISABLE_WERROR) @@ -36,24 +38,26 @@ macro(_SETUP_PROJECT_WARNINGS) # For win32 systems, it is impossible to use Wall, especially with boost, # which is way too verbose The default levels (W3/W4) are enough The next # macro remove warnings on deprecations due to stl. - set(MSVC_FLAGS - -D_SCL_SECURE_NO_WARNINGS - -D_CRT_SECURE_NO_WARNINGS - -D_CRT_SECURE_NO_DEPRECATE - # -- The following warnings are removed to highlight the output C4101 The - # local variable is never used removed since happens frequently in - # headers. - /wd4101 - # C4250 'class1' : inherits 'class2::member' via dominance - /wd4250 - # C4251 class 'type' needs to have dll-interface to be used by clients of - # class 'type2' ~ in practice, raised by the classes that have non-dll - # attribute (such as std::vector) - /wd4251 - # C4275 non - DLL-interface used as base for DLL-interface - /wd4275 - # C4355 "this" used in base member initializer list - /wd4355) + set( + MSVC_FLAGS + -D_SCL_SECURE_NO_WARNINGS + -D_CRT_SECURE_NO_WARNINGS + -D_CRT_SECURE_NO_DEPRECATE + # -- The following warnings are removed to highlight the output C4101 The + # local variable is never used removed since happens frequently in + # headers. + /wd4101 + # C4250 'class1' : inherits 'class2::member' via dominance + /wd4250 + # C4251 class 'type' needs to have dll-interface to be used by clients of + # class 'type2' ~ in practice, raised by the classes that have non-dll + # attribute (such as std::vector) + /wd4251 + # C4275 non - DLL-interface used as base for DLL-interface + /wd4275 + # C4355 "this" used in base member initializer list + /wd4355 + ) cxx_flags_by_compiler_frontend( GNU @@ -62,7 +66,8 @@ macro(_SETUP_PROJECT_WARNINGS) ${MSVC_FLAGS} OUTPUT WARNING_CXX_FLAGS_LIST - FILTER) + FILTER + ) string(REPLACE ";" " " WARNING_CXX_FLAGS "${WARNING_CXX_FLAGS_LIST}") set(CMAKE_CXX_FLAGS "${WARNING_CXX_FLAGS} ${CMAKE_CXX_FLAGS}") @@ -108,8 +113,13 @@ function(CXX_FLAGS_BY_COMPILER_FRONTEND) set(options FILTER) set(oneValueArgs OUTPUT) set(multiValueArgs GNU MSVC) - cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" - ${ARGN}) + cmake_parse_arguments( + ARGS + "${options}" + "${oneValueArgs}" + "${multiValueArgs}" + ${ARGN} + ) # Before CMake 3.14, the CMAKE_CXX_COMPILER_FRONTEND_VARIANT doesn't exists. # Before CMake 3.26, when CMAKE_CXX_COMPILER_ID is set to GNU, MSVC or @@ -121,13 +131,17 @@ function(CXX_FLAGS_BY_COMPILER_FRONTEND) set(FLAGS ${ARGS_MSVC}) else() message( - WARNING "Unknown compiler frontend for '${CMAKE_CXX_COMPILER_ID}' " - "with frontend '${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}'\n" - "No flags outputed") + WARNING + "Unknown compiler frontend for '${CMAKE_CXX_COMPILER_ID}' " + "with frontend '${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}'\n" + "No flags outputed" + ) endif() else() - if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_SIMULATE_ID MATCHES - "MSVC") + if( + CMAKE_CXX_COMPILER_ID MATCHES "Clang" + AND CMAKE_CXX_SIMULATE_ID MATCHES "MSVC" + ) set(FLAGS ${ARGS_MSVC}) elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") set(FLAGS ${ARGS_MSVC}) @@ -135,9 +149,11 @@ function(CXX_FLAGS_BY_COMPILER_FRONTEND) set(FLAGS ${ARGS_GNU}) else() message( - WARNING "Unknown compiler frontend for '${CMAKE_CXX_COMPILER_ID}' " - "with simulated ID '${CMAKE_CXX_SIMULATED_ID}'\n" - "No flags outputed") + WARNING + "Unknown compiler frontend for '${CMAKE_CXX_COMPILER_ID}' " + "with simulated ID '${CMAKE_CXX_SIMULATED_ID}'\n" + "No flags outputed" + ) endif() endif() @@ -152,7 +168,5 @@ function(CXX_FLAGS_BY_COMPILER_FRONTEND) set(FILTERED_FLAGS ${FLAGS}) endif() - set(${ARGS_OUTPUT} - ${FILTERED_FLAGS} - PARENT_SCOPE) + set(${ARGS_OUTPUT} ${FILTERED_FLAGS} PARENT_SCOPE) endfunction() diff --git a/coverage.cmake b/coverage.cmake index 6a626a240..c760f1d3b 100644 --- a/coverage.cmake +++ b/coverage.cmake @@ -24,27 +24,38 @@ endif() function(enable_coverage target) message( WARNING - "the 'enable_coverage' CMake function is deprecated and does nothing.") + "the 'enable_coverage' CMake function is deprecated and does nothing." + ) endfunction() if(ENABLE_COVERAGE) - set(CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} -O0 -g --coverage" - CACHE STRING "coverage flags") + set( + CMAKE_CXX_FLAGS + "${CMAKE_CXX_FLAGS} -O0 -g --coverage" + CACHE STRING + "coverage flags" + ) find_program( - KCOV kcov DOC "kcov is required for use with -DENABLE_COVERAGE=ON" REQUIRED) + KCOV + kcov + DOC "kcov is required for use with -DENABLE_COVERAGE=ON" + REQUIRED + ) set(KCOV_DIR "${CMAKE_BINARY_DIR}/kcov") file(MAKE_DIRECTORY ${KCOV_DIR}) endif() macro(_SETUP_COVERAGE_FINALIZE) if(NOT TARGET coverage) - add_custom_target(coverage - COMMENT "Generating HTML report for code coverage") + add_custom_target( + coverage + COMMENT "Generating HTML report for code coverage" + ) add_custom_target( ${PROJECT_NAME}-coverage COMMAND ${KCOV} --merge ${CMAKE_BINARY_DIR}/coverage ${KCOV_DIR}/* - COMMENT "Generating HTML report for code coverage") + COMMENT "Generating HTML report for code coverage" + ) add_dependencies(coverage ${PROJECT_NAME}-coverage) endif() endmacro() diff --git a/cpack.cmake b/cpack.cmake index 612b0b2ed..3dd68a9a0 100644 --- a/cpack.cmake +++ b/cpack.cmake @@ -29,10 +29,15 @@ macro(ADD_CMAKE_DEPENDENCY PKG_CONFIG_STRING) string(REGEX MATCH "[^<>= ]+" LIBRARY_NAME "${PKG_CONFIG_STRING}") # Carefull the space in front of the matching string is important to avoid # confusion with package name. - string(REGEX MATCHALL " [0-9]+.[0-9]+(.[a-z0-9-])*" VERSION - "${PKG_CONFIG_STRING}") + string( + REGEX MATCHALL + " [0-9]+.[0-9]+(.[a-z0-9-])*" + VERSION + "${PKG_CONFIG_STRING}" + ) _add_to_list(CPACK_INTERNAL_CONFIG_REQUIRES "${LIBRARY_NAME}(>=${VERSION})" - ",") + "," + ) endmacro(ADD_CMAKE_DEPENDENCY) # SETUP_PROJECT_CPACK @@ -52,18 +57,27 @@ macro(SETUP_PROJECT_CPACK) set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) set(CPACK_PACKAGE_DESCRIPTION_FILE ${PROJECT_SOURCE_DIR}/README.md) - set(CPACK_DEBIAN_PACKAGE_MAINTAINER - "Olivier Stasse (olivier.stasse@aist.go.jp)") + set( + CPACK_DEBIAN_PACKAGE_MAINTAINER + "Olivier Stasse (olivier.stasse@aist.go.jp)" + ) # The following components are regex's to match anywhere (unless anchored) in # absolute path + filename to find files or directories to be excluded from # source tarball. - set(CPACK_SOURCE_IGNORE_FILES "~$" "^${PROJECT_SOURCE_DIR}/build/" - "^${PROJECT_SOURCE_DIR}/.git/") + set( + CPACK_SOURCE_IGNORE_FILES + "~$" + "^${PROJECT_SOURCE_DIR}/build/" + "^${PROJECT_SOURCE_DIR}/.git/" + ) - set(CPACK_SOURCE_PACKAGE_FILE_NAME - "${PROJECT_NAME}-src-${PROJECT_VERSION}" - CACHE INTERNAL "tarball basename") + set( + CPACK_SOURCE_PACKAGE_FILE_NAME + "${PROJECT_NAME}-src-${PROJECT_VERSION}" + CACHE INTERNAL + "tarball basename" + ) set(CPACK_PACKAGE_NAME ${PROJECT_NAME}) set(CPACK_BINARY_DEB ON) @@ -77,5 +91,4 @@ macro(SETUP_PROJECT_CPACK) # CPack SHOULD be called after setting all the variables. SETUP_PROJECT_CPACK # is supposed to be called only once for a project. include(CPack) - endmacro(SETUP_PROJECT_CPACK) diff --git a/createshexe.cmake b/createshexe.cmake index bddca2b4d..6465c44ed 100644 --- a/createshexe.cmake +++ b/createshexe.cmake @@ -23,7 +23,8 @@ macro(CREATE_SH_EXE EXEC_NAME) if(UNIX) set(sh_exe_filename "${EXEC_NAME}.sh") file( - WRITE ${CMAKE_CURRENT_BINARY_DIR}/${sh_exe_filename} + WRITE + ${CMAKE_CURRENT_BINARY_DIR}/${sh_exe_filename} "#!/bin/sh\nLD_LIBRARY_PATH=$LD_LIBRARY_PATH:${CMAKE_INSTALL_PREFIX}/lib/plugin;export LD_LIBRARY_PATH\n./${EXEC_NAME}" ) install( @@ -36,6 +37,7 @@ macro(CREATE_SH_EXE EXEC_NAME) GROUP_EXECUTE GROUP_READ WORLD_EXECUTE - WORLD_READ) + WORLD_READ + ) endif(UNIX) endmacro(CREATE_SH_EXE) diff --git a/cxx-standard.cmake b/cxx-standard.cmake index ff3ebfd64..62072ea07 100644 --- a/cxx-standard.cmake +++ b/cxx-standard.cmake @@ -10,8 +10,11 @@ # # When this is ON, every call to :cmake:command:`CHECK_MINIMAL_CXX_STANDARD` # updates the :cmake:variable:`CMAKE_CXX_STANDARD`. -option(ENFORCE_MINIMAL_CXX_STANDARD - "Set CMAKE_CXX_STANDARD if a dependency require it" OFF) +option( + ENFORCE_MINIMAL_CXX_STANDARD + "Set CMAKE_CXX_STANDARD if a dependency require it" + OFF +) # .rst: .. ifmode:: user # @@ -30,13 +33,23 @@ macro(CHECK_MINIMAL_CXX_STANDARD STANDARD) set(options ENFORCE) set(oneValueArgs) set(multiValueArgs) - cmake_parse_arguments(MINIMAL_CXX_STANDARD "${options}" "${oneValueArgs}" - "${multiValueArgs}" ${ARGN}) + cmake_parse_arguments( + MINIMAL_CXX_STANDARD + "${options}" + "${oneValueArgs}" + "${multiValueArgs}" + ${ARGN} + ) # Get compiler default cxx standard, by printing "__cplusplus" (only once) - if(NOT DEFINED _COMPILER_DEFAULT_CXX_STANDARD - AND (NOT CMAKE_CROSSCOMPILING OR (CMAKE_CROSSCOMPILING - AND CMAKE_CROSSCOMPILING_EMULATOR))) + if( + NOT DEFINED _COMPILER_DEFAULT_CXX_STANDARD + AND + ( + NOT CMAKE_CROSSCOMPILING + OR (CMAKE_CROSSCOMPILING AND CMAKE_CROSSCOMPILING_EMULATOR) + ) + ) if(MSVC) # See # https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/ @@ -47,37 +60,49 @@ macro(CHECK_MINIMAL_CXX_STANDARD STANDARD) "#include \nint main(){std::cout << __cplusplus << std::endl;return 0;}" ) try_run( - _cxx_standard_run_status _cxx_standard_build_status + _cxx_standard_run_status + _cxx_standard_build_status ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/cmake/tmp-cxx-standard.cpp - RUN_OUTPUT_VARIABLE _COMPILER_DEFAULT_CXX_STANDARD) - if(_cxx_standard_run_status EQUAL FAILED_TO_RUN - OR NOT _cxx_standard_build_status) + RUN_OUTPUT_VARIABLE _COMPILER_DEFAULT_CXX_STANDARD + ) + if( + _cxx_standard_run_status EQUAL FAILED_TO_RUN + OR NOT _cxx_standard_build_status + ) message( WARNING - "Impossible to build or run the script to retrive the _COMPILER_DEFAULT_CXX_STANDARD quantity from current compiler. Setting _COMPILER_DEFAULT_CXX_STANDARD to 199711" + "Impossible to build or run the script to retrive the _COMPILER_DEFAULT_CXX_STANDARD quantity from current compiler. Setting _COMPILER_DEFAULT_CXX_STANDARD to 199711" ) set(_COMPILER_DEFAULT_CXX_STANDARD "199711") endif() - string(STRIP "${_COMPILER_DEFAULT_CXX_STANDARD}" - _COMPILER_DEFAULT_CXX_STANDARD) + string( + STRIP + "${_COMPILER_DEFAULT_CXX_STANDARD}" + _COMPILER_DEFAULT_CXX_STANDARD + ) message(STATUS "Default C++ standard: ${_COMPILER_DEFAULT_CXX_STANDARD}") endif() # Check if we need to upgrade the current minimum - if(NOT DEFINED _MINIMAL_CXX_STANDARD - OR (NOT ${STANDARD} EQUAL "98" - AND (_MINIMAL_CXX_STANDARD EQUAL "98" OR _MINIMAL_CXX_STANDARD LESS - ${STANDARD}))) - set(_MINIMAL_CXX_STANDARD - "${STANDARD}" - CACHE INTERNAL "") + if( + NOT DEFINED _MINIMAL_CXX_STANDARD + OR + ( + NOT ${STANDARD} EQUAL "98" + AND + ( + _MINIMAL_CXX_STANDARD EQUAL "98" + OR _MINIMAL_CXX_STANDARD LESS ${STANDARD} + ) + ) + ) + set(_MINIMAL_CXX_STANDARD "${STANDARD}" CACHE INTERNAL "") message(STATUS "Minimal C++ standard upgraded to ${_MINIMAL_CXX_STANDARD}") endif() # Check if a non-trivial minimum has been requested if(DEFINED _MINIMAL_CXX_STANDARD AND NOT _MINIMAL_CXX_STANDARD EQUAL 98) - if(DEFINED CMAKE_CXX_STANDARD) set(_CURRENT_STANDARD ${CMAKE_CXX_STANDARD}) elseif(DEFINED _COMPILER_DEFAULT_CXX_STANDARD) @@ -94,13 +119,15 @@ macro(CHECK_MINIMAL_CXX_STANDARD STANDARD) set(_CURRENT_STANDARD 17) # C++20: g++-9 defines c++2a with literal 201709, g++-11 & clang-10 # define c++2a with literal 202002 - elseif(_COMPILER_DEFAULT_CXX_STANDARD EQUAL 201709 - OR _COMPILER_DEFAULT_CXX_STANDARD EQUAL 202002) + elseif( + _COMPILER_DEFAULT_CXX_STANDARD EQUAL 201709 + OR _COMPILER_DEFAULT_CXX_STANDARD EQUAL 202002 + ) set(_CURRENT_STANDARD 20) else() message( FATAL_ERROR - "Unknown current C++ standard ${_COMPILER_DEFAULT_CXX_STANDARD} while trying to check for >= ${_MINIMAL_CXX_STANDARD}" + "Unknown current C++ standard ${_COMPILER_DEFAULT_CXX_STANDARD} while trying to check for >= ${_MINIMAL_CXX_STANDARD}" ) endif() else() @@ -108,23 +135,27 @@ macro(CHECK_MINIMAL_CXX_STANDARD STANDARD) endif() # Check that the requested minimum is higher than the currently selected - if(_CURRENT_STANDARD EQUAL 98 OR _CURRENT_STANDARD LESS - _MINIMAL_CXX_STANDARD) + if( + _CURRENT_STANDARD EQUAL 98 + OR _CURRENT_STANDARD LESS _MINIMAL_CXX_STANDARD + ) message( STATUS - "Incompatible C++ standard detected: upgrade required from ${_CURRENT_STANDARD} to >= ${_MINIMAL_CXX_STANDARD}" + "Incompatible C++ standard detected: upgrade required from ${_CURRENT_STANDARD} to >= ${_MINIMAL_CXX_STANDARD}" ) # Check that the requested minimum is higher than any pre-existing # CMAKE_CXX_STANDARD - if(NOT CMAKE_CXX_STANDARD - OR CMAKE_CXX_STANDARD EQUAL 98 - OR CMAKE_CXX_STANDARD LESS _MINIMAL_CXX_STANDARD) + if( + NOT CMAKE_CXX_STANDARD + OR CMAKE_CXX_STANDARD EQUAL 98 + OR CMAKE_CXX_STANDARD LESS _MINIMAL_CXX_STANDARD + ) # Throw error if a specific version is required and the currently # desired one is incompatible if(CMAKE_CXX_STANDARD_REQUIRED) message( FATAL_ERROR - "CMAKE_CXX_STANDARD_REQUIRED set - cannot upgrade incompatible standard" + "CMAKE_CXX_STANDARD_REQUIRED set - cannot upgrade incompatible standard" ) endif() # Enforcing a standard version is required - check if we can upgrade @@ -133,26 +164,28 @@ macro(CHECK_MINIMAL_CXX_STANDARD STANDARD) set(CMAKE_CXX_STANDARD ${_MINIMAL_CXX_STANDARD}) message( STATUS - "CMAKE_CXX_STANDARD automatically upgraded from ${_CURRENT_STANDARD} to ${CMAKE_CXX_STANDARD}" + "CMAKE_CXX_STANDARD automatically upgraded from ${_CURRENT_STANDARD} to ${CMAKE_CXX_STANDARD}" ) else() message( FATAL_ERROR - "CMAKE_CXX_STANDARD upgrade from ${_CURRENT_STANDARD} to >= ${_MINIMAL_CXX_STANDARD} required" + "CMAKE_CXX_STANDARD upgrade from ${_CURRENT_STANDARD} to >= ${_MINIMAL_CXX_STANDARD} required" ) endif() endif() else() # requested minimum is higher than the currently selected message( STATUS - "C++ standard sufficient: Minimal required ${_MINIMAL_CXX_STANDARD}, currently defined: ${_CURRENT_STANDARD}" + "C++ standard sufficient: Minimal required ${_MINIMAL_CXX_STANDARD}, currently defined: ${_CURRENT_STANDARD}" ) # current C++ standard was not set in CMake but we enforce it - if(NOT DEFINED CMAKE_CXX_STANDARD AND (ENFORCE_MINIMAL_CXX_STANDARD - OR MINIMAL_CXX_STANDARD_ENFORCE)) + if( + NOT DEFINED CMAKE_CXX_STANDARD + AND (ENFORCE_MINIMAL_CXX_STANDARD OR MINIMAL_CXX_STANDARD_ENFORCE) + ) message( STATUS - "CMAKE_CXX_STANDARD was not set: automatically set to currently defined standard ${_CURRENT_STANDARD}" + "CMAKE_CXX_STANDARD was not set: automatically set to currently defined standard ${_CURRENT_STANDARD}" ) set(CMAKE_CXX_STANDARD ${_CURRENT_STANDARD}) endif() diff --git a/cxx11.cmake b/cxx11.cmake index a3b623d8d..c83d3feaa 100644 --- a/cxx11.cmake +++ b/cxx11.cmake @@ -23,6 +23,7 @@ macro(PROJECT_USE_CXX11) message( DEPRECATION - "This macro is deprecated. Use CHECK_MINIMAL_CXX_STANDARD instead.") + "This macro is deprecated. Use CHECK_MINIMAL_CXX_STANDARD instead." + ) check_minimal_cxx_standard(11 REQUIRED) endmacro(PROJECT_USE_CXX11) diff --git a/cython/cython.cmake b/cython/cython.cmake index e6015d664..59df137bd 100644 --- a/cython/cython.cmake +++ b/cython/cython.cmake @@ -19,17 +19,22 @@ if(WIN32) else() set(PYTHON_BINDING_USER_INSTALL_DEFAULT OFF) endif() -option(PYTHON_BINDING_USER_INSTALL "Install the Python binding in user space" - ${PYTHON_BINDING_USER_INSTALL_DEFAULT}) +option( + PYTHON_BINDING_USER_INSTALL + "Install the Python binding in user space" + ${PYTHON_BINDING_USER_INSTALL_DEFAULT} +) option(PYTHON_BINDING_FORCE_PYTHON2 "Use python2 instead of python" OFF) option(PYTHON_BINDING_FORCE_PYTHON3 "Use python3 instead of python" OFF) set(PYTHON_BINDING_BUILD_PYTHON2_AND_PYTHON3_DEFAULT OFF) if(DEFINED PYTHON_DEB_ROOT) set(PYTHON_BINDING_BUILD_PYTHON2_AND_PYTHON3_DEFAULT ON) endif() -option(PYTHON_BINDING_BUILD_PYTHON2_AND_PYTHON3 - "Build Python 2 and Python 3 bindings" - ${PYTHON_BINDING_BUILD_PYTHON2_AND_PYTHON3_DEFAULT}) +option( + PYTHON_BINDING_BUILD_PYTHON2_AND_PYTHON3 + "Build Python 2 and Python 3 bindings" + ${PYTHON_BINDING_BUILD_PYTHON2_AND_PYTHON3_DEFAULT} +) if(${PYTHON_BINDING_FORCE_PYTHON2} AND ${PYTHON_BINDING_FORCE_PYTHON3}) message(FATAL_ERROR "Cannot enforce Python 2 and Python 3 at the same time") endif() @@ -79,8 +84,11 @@ macro(_setup_python_for_cython) set(Python2_EXECUTABLE ${DEFAULT_PYTHON2_EXECUTABLE}) endif() endif() - find_package(${PYTHON_VERSION} REQUIRED COMPONENTS Interpreter - Development NumPy) + find_package( + ${PYTHON_VERSION} + REQUIRED + COMPONENTS Interpreter Development NumPy + ) endforeach() endif() endmacro() @@ -89,11 +97,17 @@ endmacro() # from an interface library macro(_CYTHON_DUMMY_TARGET TARGET) if(NOT TARGET _cython_dummy_${TARGET}) - add_library(_cython_dummy_${TARGET} SHARED EXCLUDE_FROM_ALL - "${CYTHON_DUMMY_CPP_LOCATION}") + add_library( + _cython_dummy_${TARGET} + SHARED + EXCLUDE_FROM_ALL + "${CYTHON_DUMMY_CPP_LOCATION}" + ) target_link_libraries(_cython_dummy_${TARGET} PUBLIC ${TARGET}) - set_target_properties(_cython_dummy_${TARGET} PROPERTIES FOLDER - "bindings/details") + set_target_properties( + _cython_dummy_${TARGET} + PROPERTIES FOLDER "bindings/details" + ) endif() endmacro() @@ -122,7 +136,9 @@ macro(_pip_has_install_system PYTHON OUT) execute_process( COMMAND ${PYTHON} -m pip install --system RESULT_VARIABLE ${OUT} - OUTPUT_QUIET ERROR_QUIET) + OUTPUT_QUIET + ERROR_QUIET + ) if(${${OUT}} EQUAL 0) set(${OUT} True) else() @@ -139,46 +155,58 @@ macro( SOURCES GENERATE_SOURCES TARGETS - WITH_TESTS) - set(SETUP_LOCATION - "${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE}/${PYTHON}/$") - set(${PACKAGE}_${PYTHON}_SETUP_LOCATION - "${SETUP_LOCATION}" - CACHE INTERNAL "") + WITH_TESTS +) + set( + SETUP_LOCATION + "${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE}/${PYTHON}/$" + ) + set(${PACKAGE}_${PYTHON}_SETUP_LOCATION "${SETUP_LOCATION}" CACHE INTERNAL "") if(TARGET cython_${PYTHON}_${PACKAGE}) - target_include_directories(cython_${PYTHON}_${PACKAGE} - INTERFACE "${SETUP_LOCATION}") + target_include_directories( + cython_${PYTHON}_${PACKAGE} + INTERFACE "${SETUP_LOCATION}" + ) endif() if(DEFINED CMAKE_BUILD_TYPE) - file(MAKE_DIRECTORY - "${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE}/${PYTHON}/${CMAKE_BUILD_TYPE}") + file( + MAKE_DIRECTORY + "${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE}/${PYTHON}/${CMAKE_BUILD_TYPE}" + ) else() foreach(CFG ${CMAKE_CONFIGURATION_TYPES}) - file(MAKE_DIRECTORY - "${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE}/${PYTHON}/${CFG}") + file( + MAKE_DIRECTORY + "${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE}/${PYTHON}/${CFG}" + ) endforeach() endif() file( - GENERATE - OUTPUT "${SETUP_LOCATION}/setup.py" - INPUT "${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE}/setup.in.py") + GENERATE OUTPUT + "${SETUP_LOCATION}/setup.py" + INPUT "${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE}/setup.in.py" + ) # Target to build the bindings set(TARGET_NAME ${PACKAGE}-${PYTHON}-bindings) add_custom_target( - ${TARGET_NAME} ALL - COMMAND ${CMAKE_COMMAND} -E chdir "${SETUP_LOCATION}" ${PYTHON} setup.py - build_ext --inplace + ${TARGET_NAME} + ALL + COMMAND + ${CMAKE_COMMAND} -E chdir "${SETUP_LOCATION}" ${PYTHON} setup.py build_ext + --inplace COMMENT "Generating local ${PACKAGE} ${PYTHON} bindings" DEPENDS ${SOURCES} ${GENERATE_SOURCES} - SOURCES ${SOURCES} ${GENERATE_SOURCES}) + SOURCES ${SOURCES} ${GENERATE_SOURCES} + ) set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "bindings") add_dependencies(${TARGET_NAME} ${TARGETS}) # Copy sources foreach(F ${GENERATE_SOURCES}) file( - GENERATE - OUTPUT "${SETUP_LOCATION}/${F}" - INPUT "${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE}/configured/${F}") + GENERATE OUTPUT + "${SETUP_LOCATION}/${F}" + INPUT "${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE}/configured/${F}" + ) endforeach() set(I 0) foreach(SRC ${SOURCES}) @@ -186,7 +214,7 @@ macro( if(NOT ${SRC} MATCHES "^${CMAKE_CURRENT_BINARY_DIR}") message( FATAL_ERROR - "Source provided to ADD_CYTHON_BINDINGS must have a relative path or an absolute path in CMAKE_CURRENT_BINARY_DIR (${CMAKE_CURRENT_BINARY_DIR})" + "Source provided to ADD_CYTHON_BINDINGS must have a relative path or an absolute path in CMAKE_CURRENT_BINARY_DIR (${CMAKE_CURRENT_BINARY_DIR})" ) endif() file(RELATIVE_PATH REL_SRC "${CMAKE_CURRENT_BINARY_DIR}" "${SRC}") @@ -199,18 +227,23 @@ macro( add_custom_target( copy-sources-${I}-${TARGET_NAME} COMMAND ${CMAKE_COMMAND} -E copy_if_different ${FILE_IN} ${FILE_OUT} - DEPENDS ${FILE_IN}) - set_target_properties(copy-sources-${I}-${TARGET_NAME} - PROPERTIES FOLDER "bindings/details") + DEPENDS ${FILE_IN} + ) + set_target_properties( + copy-sources-${I}-${TARGET_NAME} + PROPERTIES FOLDER "bindings/details" + ) add_dependencies(${TARGET_NAME} copy-sources-${I}-${TARGET_NAME}) math(EXPR I "${I} + 1") endforeach() # Manual target to force regeneration add_custom_target( force-${TARGET_NAME} - COMMAND ${CMAKE_COMMAND} -E chdir "${SETUP_LOCATION}" ${PYTHON} setup.py - build_ext --inplace --force - COMMENT "Generating local ${PACKAGE} ${PYTHON} bindings (forced)") + COMMAND + ${CMAKE_COMMAND} -E chdir "${SETUP_LOCATION}" ${PYTHON} setup.py build_ext + --inplace --force + COMMENT "Generating local ${PACKAGE} ${PYTHON} bindings (forced)" + ) set_target_properties(force-${TARGET_NAME} PROPERTIES FOLDER "bindings") # Tests if(${WITH_TESTS} AND ${BUILD_TESTING}) @@ -225,8 +258,10 @@ macro( foreach(TGT ${TARGETS}) _is_interface_library(${TGT} IS_INTERFACE) if(NOT ${IS_INTERFACE}) - set(EXTRA_LD_PATH - "$${PATH_SEP}${EXTRA_LD_PATH}") + set( + EXTRA_LD_PATH + "$${PATH_SEP}${EXTRA_LD_PATH}" + ) endif() endforeach() if(${WITH_TESTS}) @@ -235,16 +270,19 @@ macro( COMMAND ${CMAKE_COMMAND} -E env "${ENV_VAR}=${EXTRA_LD_PATH}$ENV{${ENV_VAR}}" ${CMAKE_COMMAND} -E env "PYTHONPATH=.${PATH_SEP}$ENV{PYTHONPATH}" - ${CMAKE_COMMAND} -E chdir "${SETUP_LOCATION}" ${PYTHON} -m pytest) + ${CMAKE_COMMAND} -E chdir "${SETUP_LOCATION}" ${PYTHON} -m pytest + ) endif() endif() # Install targets if(DEFINED PYTHON_DEB_ROOT) add_custom_target( install-${TARGET_NAME} - COMMAND ${CMAKE_COMMAND} -E chdir "${SETUP_LOCATION}" ${PYTHON} setup.py - install --root=${PYTHON_DEB_ROOT} --install-layout=deb - COMMENT "Install ${PACKAGE} ${PYTHON} bindings (Debian layout)") + COMMAND + ${CMAKE_COMMAND} -E chdir "${SETUP_LOCATION}" ${PYTHON} setup.py install + --root=${PYTHON_DEB_ROOT} --install-layout=deb + COMMENT "Install ${PACKAGE} ${PYTHON} bindings (Debian layout)" + ) else() set(PIP_EXTRA_OPTIONS "") if(${PYTHON_BINDING_USER_INSTALL}) @@ -257,9 +295,12 @@ macro( ${PYTHON} -c "import sys; print(\"python{}.{}\".format(sys.version_info.major, sys.version_info.minor));" OUTPUT_VARIABLE PYTHON_VERSION - OUTPUT_STRIP_TRAILING_WHITESPACE) - set(PIP_TARGET - "${PIP_INSTALL_PREFIX}/lib/${PYTHON_VERSION}/site-packages/") + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + set( + PIP_TARGET + "${PIP_INSTALL_PREFIX}/lib/${PYTHON_VERSION}/site-packages/" + ) set(PIP_EXTRA_OPTIONS --target "${PIP_TARGET}") if(${PIP_HAS_INSTALL_SYSTEM}) set(PIP_EXTRA_OPTIONS --system ${PIP_EXTRA_OPTIONS}) @@ -267,20 +308,25 @@ macro( endif() add_custom_target( install-${TARGET_NAME} - COMMAND ${CMAKE_COMMAND} -E chdir "${SETUP_LOCATION}" ${PYTHON} -m pip - install . ${PIP_EXTRA_OPTIONS} --upgrade - COMMENT "Install ${PACKAGE} ${PYTHON} bindings") + COMMAND + ${CMAKE_COMMAND} -E chdir "${SETUP_LOCATION}" ${PYTHON} -m pip install . + ${PIP_EXTRA_OPTIONS} --upgrade + COMMENT "Install ${PACKAGE} ${PYTHON} bindings" + ) set_target_properties(install-${TARGET_NAME} PROPERTIES FOLDER "bindings") add_custom_target( uninstall-${TARGET_NAME} - COMMAND ${CMAKE_COMMAND} -E chdir "${SETUP_LOCATION}" ${PYTHON} -m pip - uninstall -y ${PACKAGE} - COMMENT "Removing ${PACKAGE} ${PYTHON} bindings") + COMMAND + ${CMAKE_COMMAND} -E chdir "${SETUP_LOCATION}" ${PYTHON} -m pip uninstall + -y ${PACKAGE} + COMMENT "Removing ${PACKAGE} ${PYTHON} bindings" + ) set_target_properties(uninstall-${TARGET_NAME} PROPERTIES FOLDER "bindings") add_dependencies(uninstall uninstall-${TARGET_NAME}) endif() install( - CODE "EXECUTE_PROCESS(COMMAND \"${CMAKE_COMMAND}\" --build \"${CMAKE_BINARY_DIR}\" --config \${CMAKE_INSTALL_CONFIG_NAME} --target install-${TARGET_NAME})" + CODE + "EXECUTE_PROCESS(COMMAND \"${CMAKE_COMMAND}\" --build \"${CMAKE_BINARY_DIR}\" --config \${CMAKE_INSTALL_CONFIG_NAME} --target install-${TARGET_NAME})" ) endmacro() @@ -318,10 +364,21 @@ endmacro() macro(ADD_CYTHON_BINDINGS PACKAGE) set(options) set(oneValueArgs VERSION) - set(multiValueArgs MODULES TARGETS EXPORT_SOURCES PRIVATE_SOURCES - GENERATE_SOURCES) - cmake_parse_arguments(CYTHON_BINDINGS "${options}" "${oneValueArgs}" - "${multiValueArgs}" ${ARGN}) + set( + multiValueArgs + MODULES + TARGETS + EXPORT_SOURCES + PRIVATE_SOURCES + GENERATE_SOURCES + ) + cmake_parse_arguments( + CYTHON_BINDINGS + "${options}" + "${oneValueArgs}" + "${multiValueArgs}" + ${ARGN} + ) if(NOT DEFINED CYTHON_BINDINGS_VERSION) set(CYTHON_BINDINGS_VERSION ${PROJECT_VERSION}) endif() @@ -340,7 +397,7 @@ macro(ADD_CYTHON_BINDINGS PACKAGE) if(NOT DEFINED CYTHON_BINDINGS_TARGETS) message( FATAL_ERROR - "Error in ADD_CYTHON_BINDINGS, bindings should depend on at least one target" + "Error in ADD_CYTHON_BINDINGS, bindings should depend on at least one target" ) endif() # Setup the basic setup script @@ -365,72 +422,118 @@ macro(ADD_CYTHON_BINDINGS PACKAGE) _is_interface_library(${TGT} IS_INTERFACE) if(${IS_INTERFACE}) _cython_dummy_target(${TGT}) - list(APPEND CYTHON_BINDINGS_COMPILE_DEFINITIONS - "$") list( - APPEND CYTHON_BINDINGS_COMPILE_DEFINITIONS - "$") - list(APPEND CYTHON_BINDINGS_CXX_STANDARD - "$") - list(APPEND CYTHON_BINDINGS_INCLUDE_DIRECTORIES - "$") + APPEND + CYTHON_BINDINGS_COMPILE_DEFINITIONS + "$" + ) + list( + APPEND + CYTHON_BINDINGS_COMPILE_DEFINITIONS + "$" + ) + list( + APPEND + CYTHON_BINDINGS_CXX_STANDARD + "$" + ) + list( + APPEND + CYTHON_BINDINGS_INCLUDE_DIRECTORIES + "$" + ) list( - APPEND CYTHON_BINDINGS_INCLUDE_DIRECTORIES - "$") - list(APPEND CYTHON_BINDINGS_LINK_FLAGS - "$") + APPEND + CYTHON_BINDINGS_INCLUDE_DIRECTORIES + "$" + ) + list( + APPEND + CYTHON_BINDINGS_LINK_FLAGS + "$" + ) else() _is_static_library(${TGT} IS_STATIC) - list(APPEND CYTHON_BINDINGS_COMPILE_DEFINITIONS - "$") - list(APPEND CYTHON_BINDINGS_COMPILE_DEFINITIONS - "$") - list(APPEND CYTHON_BINDINGS_CXX_STANDARD - "$") - list(APPEND CYTHON_BINDINGS_INCLUDE_DIRECTORIES - "$") - list(APPEND CYTHON_BINDINGS_INCLUDE_DIRECTORIES - "$") - list(APPEND CYTHON_BINDINGS_LINK_FLAGS - "$") + list( + APPEND + CYTHON_BINDINGS_COMPILE_DEFINITIONS + "$" + ) + list( + APPEND + CYTHON_BINDINGS_COMPILE_DEFINITIONS + "$" + ) + list( + APPEND + CYTHON_BINDINGS_CXX_STANDARD + "$" + ) + list( + APPEND + CYTHON_BINDINGS_INCLUDE_DIRECTORIES + "$" + ) + list( + APPEND + CYTHON_BINDINGS_INCLUDE_DIRECTORIES + "$" + ) + list( + APPEND + CYTHON_BINDINGS_LINK_FLAGS + "$" + ) list(APPEND CYTHON_BINDINGS_LIBRARIES "$") list(APPEND CYTHON_BINDINGS_TARGET_FILES "$") if(${IS_STATIC}) - list(APPEND CYTHON_BINDINGS_STATIC_LIBRARIES - "$") + list( + APPEND + CYTHON_BINDINGS_STATIC_LIBRARIES + "$" + ) endif() endif() endforeach() - configure_file("${CYTHON_SETUP_IN_PY_LOCATION}" - "${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE}/setup.in.py") + configure_file( + "${CYTHON_SETUP_IN_PY_LOCATION}" + "${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE}/setup.in.py" + ) foreach(F ${CYTHON_BINDINGS_GENERATE_SOURCES}) - configure_file(${F} - "${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE}/configured/${F}") + configure_file( + ${F} + "${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE}/configured/${F}" + ) endforeach() if(${PYTHON_BINDING_BUILD_PYTHON2_AND_PYTHON3}) _add_cython_bindings_targets( "python2" ${PACKAGE} "${CYTHON_BINDINGS_SOURCES}" "${CYTHON_BINDINGS_GENERATE_SOURCES}" "${CYTHON_BINDINGS_TARGETS}" - ${WITH_TESTS}) + ${WITH_TESTS} + ) _add_cython_bindings_targets( "python3" ${PACKAGE} "${CYTHON_BINDINGS_SOURCES}" "${CYTHON_BINDINGS_GENERATE_SOURCES}" "${CYTHON_BINDINGS_TARGETS}" - ${WITH_TESTS}) + ${WITH_TESTS} + ) elseif(${PYTHON_BINDING_FORCE_PYTHON3}) _add_cython_bindings_targets( "python3" ${PACKAGE} "${CYTHON_BINDINGS_SOURCES}" "${CYTHON_BINDINGS_GENERATE_SOURCES}" "${CYTHON_BINDINGS_TARGETS}" - ${WITH_TESTS}) + ${WITH_TESTS} + ) elseif(${PYTHON_BINDING_FORCE_PYTHON2}) _add_cython_bindings_targets( "python2" ${PACKAGE} "${CYTHON_BINDINGS_SOURCES}" "${CYTHON_BINDINGS_GENERATE_SOURCES}" "${CYTHON_BINDINGS_TARGETS}" - ${WITH_TESTS}) + ${WITH_TESTS} + ) else() _add_cython_bindings_targets( "python" ${PACKAGE} "${CYTHON_BINDINGS_SOURCES}" "${CYTHON_BINDINGS_GENERATE_SOURCES}" "${CYTHON_BINDINGS_TARGETS}" - ${WITH_TESTS}) + ${WITH_TESTS} + ) endif() endmacro() @@ -446,16 +549,20 @@ macro(_MAKE_CYTHON_LIBRARY PACKAGE PYTHON PYTHON_B OUT) execute_process( COMMAND ${PYTHON_B} -c "import sys; print(sys.version_info.major);" OUTPUT_VARIABLE ${PYTHON}_FIND_VERSION_MAJOR - OUTPUT_STRIP_TRAILING_WHITESPACE) + OUTPUT_STRIP_TRAILING_WHITESPACE + ) execute_process( COMMAND ${PYTHON_B} -c "import sys; print(sys.version_info.minor);" OUTPUT_VARIABLE ${PYTHON}_FIND_VERSION_MINOR - OUTPUT_STRIP_TRAILING_WHITESPACE) + OUTPUT_STRIP_TRAILING_WHITESPACE + ) find_package(${PYTHON} REQUIRED COMPONENTS Interpreter Development) add_library(${TGT_NAME} INTERFACE) target_link_libraries(${TGT_NAME} INTERFACE ${${PYTHON}_LIBRARIES}) - target_include_directories(${TGT_NAME} - INTERFACE "${${PYTHON}_INCLUDE_DIRS}") + target_include_directories( + ${TGT_NAME} + INTERFACE "${${PYTHON}_INCLUDE_DIRS}" + ) if(DEFINED ${SETUP_LOCATION_VAR}) set(SETUP_LOCATION "${${SETUP_LOCATION_VAR}}") target_include_directories(${TGT_NAME} INTERFACE "${SETUP_LOCATION}") @@ -494,13 +601,14 @@ macro(GET_CYTHON_LIBRARIES PACKAGE VAR) execute_process( COMMAND python -c "import sys; print(sys.version_info.major);" OUTPUT_VARIABLE PYTHON_MAJOR - OUTPUT_STRIP_TRAILING_WHITESPACE) + OUTPUT_STRIP_TRAILING_WHITESPACE + ) if("${PYTHON_MAJOR}" STREQUAL "2" OR "${PYTHON_MAJOR}" STREQUAL "3") _append_cython_library(${PACKAGE} Python${PYTHON_MAJOR} python ${VAR}) else() message( FATAL_ERROR - "Could not determine Python major version from command line, got ${PYTHON_MAJOR}, expected 2 or 3" + "Could not determine Python major version from command line, got ${PYTHON_MAJOR}, expected 2 or 3" ) endif() endif() @@ -563,10 +671,21 @@ endmacro() function(MAKE_CYTHON_BINDINGS PACKAGE) set(options) set(oneValueArgs VERSION) - set(multiValueArgs MODULES TARGETS EXPORT_SOURCES PRIVATE_SOURCES - GENERATE_SOURCES) - cmake_parse_arguments(CYTHON_BINDINGS "${options}" "${oneValueArgs}" - "${multiValueArgs}" ${ARGN}) + set( + multiValueArgs + MODULES + TARGETS + EXPORT_SOURCES + PRIVATE_SOURCES + GENERATE_SOURCES + ) + cmake_parse_arguments( + CYTHON_BINDINGS + "${options}" + "${oneValueArgs}" + "${multiValueArgs}" + ${ARGN} + ) if(NOT DEFINED CYTHON_BINDINGS_VERSION) set(CYTHON_BINDINGS_VERSION ${PROJECT_VERSION}) endif() @@ -585,7 +704,7 @@ function(MAKE_CYTHON_BINDINGS PACKAGE) if(NOT DEFINED CYTHON_BINDINGS_TARGETS) message( FATAL_ERROR - "Error in ADD_CYTHON_BINDINGS, bindings should depend on at least one target" + "Error in ADD_CYTHON_BINDINGS, bindings should depend on at least one target" ) endif() set(CYTHON_BINDINGS_SOURCES) @@ -602,15 +721,25 @@ function(MAKE_CYTHON_BINDINGS PACKAGE) list(APPEND CYTHON_BINDINGS_COMPILE_SOURCES ${SRC}) endif() endforeach() - add_library(_cython_dummy_${PACKAGE} SHARED EXCLUDE_FROM_ALL - "${CYTHON_DUMMY_CPP_LOCATION}") - target_link_libraries(_cython_dummy_${PACKAGE} - INTERFACE ${CYTHON_BINDINGS_TARGETS}) - set_target_properties(_cython_dummy_${PACKAGE} PROPERTIES FOLDER - "bindings/details") + add_library( + _cython_dummy_${PACKAGE} + SHARED + EXCLUDE_FROM_ALL + "${CYTHON_DUMMY_CPP_LOCATION}" + ) + target_link_libraries( + _cython_dummy_${PACKAGE} + INTERFACE ${CYTHON_BINDINGS_TARGETS} + ) + set_target_properties( + _cython_dummy_${PACKAGE} + PROPERTIES FOLDER "bindings/details" + ) foreach(PYTHON ${PYTHON_BINDING_VERSIONS}) - set(PACKAGE_OUTPUT_DIRECTORY - ${CMAKE_CURRENT_BINARY_DIR}/${PYTHON}/$/${PACKAGE}) + set( + PACKAGE_OUTPUT_DIRECTORY + ${CMAKE_CURRENT_BINARY_DIR}/${PYTHON}/$/${PACKAGE} + ) if(DEFINED PYTHON_DEB_ROOT) execute_process( COMMAND @@ -618,7 +747,8 @@ function(MAKE_CYTHON_BINDINGS PACKAGE) "from distutils import sysconfig; print(sysconfig.get_python_lib(plat_specific = True, standard_lib = False))" RESULT_VARIABLE PYTHON_INSTALL_DESTINATION_FOUND OUTPUT_VARIABLE PYTHON_INSTALL_DESTINATION - OUTPUT_STRIP_TRAILING_WHITESPACE) + OUTPUT_STRIP_TRAILING_WHITESPACE + ) else() execute_process( COMMAND @@ -626,7 +756,8 @@ function(MAKE_CYTHON_BINDINGS PACKAGE) "from distutils import sysconfig; print(sysconfig.get_python_lib(prefix = '${CMAKE_INSTALL_PREFIX}', plat_specific = True))" RESULT_VARIABLE PYTHON_INSTALL_DESTINATION_FOUND OUTPUT_VARIABLE PYTHON_INSTALL_DESTINATION - OUTPUT_STRIP_TRAILING_WHITESPACE) + OUTPUT_STRIP_TRAILING_WHITESPACE + ) # Debian/Ubuntu has a specific problem here See # https://github.com/mesonbuild/meson/issues/8739 for an overview of the # problem @@ -636,31 +767,39 @@ function(MAKE_CYTHON_BINDINGS PACKAGE) ${${PYTHON}_EXECUTABLE} -c "import sys; print(\"python{}.{}\".format(sys.version_info.major, sys.version_info.minor));" OUTPUT_VARIABLE PYTHON_VERSION - OUTPUT_STRIP_TRAILING_WHITESPACE) - string(REPLACE "python3/" "${PYTHON_VERSION}/" - PYTHON_INSTALL_DESTINATION - "${PYTHON_INSTALL_DESTINATION}") + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + string( + REPLACE + "python3/" + "${PYTHON_VERSION}/" + PYTHON_INSTALL_DESTINATION + "${PYTHON_INSTALL_DESTINATION}" + ) endif() endif() foreach(F ${CYTHON_BINDINGS_GENERATE_SOURCES}) configure_file(${F} ${CMAKE_CURRENT_BINARY_DIR}/${PYTHON}/cmake/${F}) file( - GENERATE - OUTPUT ${PACKAGE_OUTPUT_DIRECTORY}/${F} - INPUT ${CMAKE_CURRENT_BINARY_DIR}/${PYTHON}/cmake/${F}) + GENERATE OUTPUT + ${PACKAGE_OUTPUT_DIRECTORY}/${F} + INPUT ${CMAKE_CURRENT_BINARY_DIR}/${PYTHON}/cmake/${F} + ) endforeach() foreach(F ${CYTHON_BINDINGS_EXPORT_SOURCES}) file( - GENERATE - OUTPUT ${PACKAGE_OUTPUT_DIRECTORY}/${F} - INPUT ${CMAKE_CURRENT_SOURCE_DIR}/${F}) + GENERATE OUTPUT + ${PACKAGE_OUTPUT_DIRECTORY}/${F} + INPUT ${CMAKE_CURRENT_SOURCE_DIR}/${F} + ) endforeach() foreach(F ${CYTHON_BINDINGS_PRIVATE_SOURCES}) if(${F} MATCHES "^tests/") file( - GENERATE - OUTPUT ${PACKAGE_OUTPUT_DIRECTORY}/${F} - INPUT ${CMAKE_CURRENT_SOURCE_DIR}/${F}) + GENERATE OUTPUT + ${PACKAGE_OUTPUT_DIRECTORY}/${F} + INPUT ${CMAKE_CURRENT_SOURCE_DIR}/${F} + ) endif() endforeach() install( @@ -669,9 +808,10 @@ function(MAKE_CYTHON_BINDINGS PACKAGE) # We can't use PACKAGE_OUTPUT_DIRECTORY because it contains a # generator-expression REGEX "^${CMAKE_CURRENT_BINARY_DIR}/${PYTHON}/[A-z]*/${PACKAGE}/tests.*" - EXCLUDE + EXCLUDE PATTERN ".pytest_cache/*" EXCLUDE - PATTERN "__pycache__/*" EXCLUDE) + PATTERN "__pycache__/*" EXCLUDE + ) # Make an uninstall rule that: # # * Remove the installed module fully (including the empty directory) @@ -680,8 +820,10 @@ function(MAKE_CYTHON_BINDINGS PACKAGE) set(UNINSTALL_TARGET_NAME uninstall-${PACKAGE}-${PYTHON}-bindings) add_custom_target( ${UNINSTALL_TARGET_NAME} - COMMAND ${CMAKE_COMMAND} -E rm -rf - ${PYTHON_INSTALL_DESTINATION}/${PACKAGE}*.dist-info) + COMMAND + ${CMAKE_COMMAND} -E rm -rf + ${PYTHON_INSTALL_DESTINATION}/${PACKAGE}*.dist-info + ) add_dependencies(uninstall ${UNINSTALL_TARGET_NAME}) if(WITH_TESTS AND BUILD_TESTING) if(WIN32) @@ -695,8 +837,10 @@ function(MAKE_CYTHON_BINDINGS PACKAGE) foreach(TGT ${CYTHON_BINDINGS_TARGETS}) _is_interface_library(${TGT} IS_INTERFACE) if(NOT ${IS_INTERFACE}) - set(EXTRA_LD_PATH - "$${PATH_SEP}${EXTRA_LD_PATH}") + set( + EXTRA_LD_PATH + "$${PATH_SEP}${EXTRA_LD_PATH}" + ) endif() endforeach() add_test( @@ -705,14 +849,17 @@ function(MAKE_CYTHON_BINDINGS PACKAGE) ${CMAKE_COMMAND} -E env "${ENV_VAR}=${EXTRA_LD_PATH}$ENV{${ENV_VAR}}" ${CMAKE_COMMAND} -E env "PYTHONPATH=.${PATH_SEP}$ENV{PYTHONPATH}" ${CMAKE_COMMAND} -E chdir "${PACKAGE_OUTPUT_DIRECTORY}" - ${${PYTHON}_EXECUTABLE} -m pytest) + ${${PYTHON}_EXECUTABLE} -m pytest + ) endif() foreach(MOD ${CYTHON_BINDINGS_MODULES}) string(REPLACE "." "/" SRC ${MOD}) set(SRC "${SRC}.pyx") if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SRC}") message( - FATAL_ERROR "Expected to find ${CMAKE_CURRENT_SOURCE_DIR}/${SRC}") + FATAL_ERROR + "Expected to find ${CMAKE_CURRENT_SOURCE_DIR}/${SRC}" + ) endif() string(REGEX REPLACE ".pyx$" ".cpp" SRC_CPP ${SRC}) string(REGEX REPLACE "/[^/]*$" "" SRC_DIR ${SRC}) @@ -732,7 +879,8 @@ function(MAKE_CYTHON_BINDINGS PACKAGE) -I${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/${SRC} DEPENDS ${CYTHON_BINDINGS_SOURCES} ${CYTHON_BINDINGS_TARGETS} - COMMAND_EXPAND_LISTS) + COMMAND_EXPAND_LISTS + ) set(TARGET_NAME ${LIB_NAME}_${PYTHON}) if(${PYTHON} STREQUAL "Python") python_add_library(${TARGET_NAME} MODULE ${CPP_OUT}) @@ -753,34 +901,49 @@ function(MAKE_CYTHON_BINDINGS PACKAGE) # Cython usually includes the deprecated NumPy API target_compile_options(${TARGET_NAME} PRIVATE -Wno-cpp) # Cython does some fishy conversions - target_compile_options(${TARGET_NAME} PRIVATE -Wno-conversion - -Wno-overflow) + target_compile_options( + ${TARGET_NAME} + PRIVATE -Wno-conversion -Wno-overflow + ) # Generating API might look like unusued variables - target_compile_options(${TARGET_NAME} PRIVATE -Wno-unused-variable - -Wno-unused-function) + target_compile_options( + ${TARGET_NAME} + PRIVATE -Wno-unused-variable -Wno-unused-function + ) endif() - target_include_directories(${TARGET_NAME} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) target_include_directories( - ${TARGET_NAME} INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/${PYTHON}) + ${TARGET_NAME} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + ) + target_include_directories( + ${TARGET_NAME} + INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/${PYTHON} + ) target_link_libraries( - ${TARGET_NAME} PUBLIC ${CYTHON_BINDINGS_TARGETS} ${PYTHON}::Python - ${PYTHON}::NumPy) + ${TARGET_NAME} + PUBLIC ${CYTHON_BINDINGS_TARGETS} ${PYTHON}::Python ${PYTHON}::NumPy + ) set_target_properties( ${TARGET_NAME} - PROPERTIES CXX_VISIBILITY_PRESET default - PREFIX "" - DEBUG_POSTFIX "" - OUTPUT_NAME ${LIB_OUTPUT_NAME} - LIBRARY_OUTPUT_DIRECTORY ${MOD_OUTPUT_DIRECTORY} - RUNTIME_OUTPUT_DIRECTORY ${MOD_OUTPUT_DIRECTORY}) + PROPERTIES + CXX_VISIBILITY_PRESET default + PREFIX "" + DEBUG_POSTFIX "" + OUTPUT_NAME ${LIB_OUTPUT_NAME} + LIBRARY_OUTPUT_DIRECTORY ${MOD_OUTPUT_DIRECTORY} + RUNTIME_OUTPUT_DIRECTORY ${MOD_OUTPUT_DIRECTORY} + ) if(NOT TARGET ${UNINSTALL_TARGET_NAME}-${MOD_FOLDER}) add_custom_target( ${UNINSTALL_TARGET_NAME}-${MOD_FOLDER} - COMMAND ${CMAKE_COMMAND} -E rm -rf - ${PYTHON_INSTALL_DESTINATION}/${MOD_FOLDER}) - add_dependencies(${UNINSTALL_TARGET_NAME} - ${UNINSTALL_TARGET_NAME}-${MOD_FOLDER}) + COMMAND + ${CMAKE_COMMAND} -E rm -rf + ${PYTHON_INSTALL_DESTINATION}/${MOD_FOLDER} + ) + add_dependencies( + ${UNINSTALL_TARGET_NAME} + ${UNINSTALL_TARGET_NAME}-${MOD_FOLDER} + ) endif() endforeach() endforeach() diff --git a/debian.cmake b/debian.cmake index a428a0178..23e8b2726 100644 --- a/debian.cmake +++ b/debian.cmake @@ -22,8 +22,11 @@ macro(_SETUP_DEBIAN) if(BUILDING_DEBIAN_PACKAGE) message(STATUS "setup debian. Trying to get the type of ${PROJECT_NAME}") get_target_property(${PROJECT_NAME}_IS_SHARED_LIBRARY ${PROJECT_NAME} TYPE) - message(STATUS "${PROJECT_NAME}_IS_SHARED_LIBRARY:" - ${${PROJECT_NAME}_IS_SHARED_LIBRARY}) + message( + STATUS + "${PROJECT_NAME}_IS_SHARED_LIBRARY:" + ${${PROJECT_NAME}_IS_SHARED_LIBRARY} + ) if(UNIX) if(IS_DIRECTORY ${PROJECT_SOURCE_DIR}/debian) @@ -36,17 +39,25 @@ macro(_SETUP_DEBIAN) RESULT_VARIABLE LGIT_DESCRIBE_RESULT OUTPUT_VARIABLE LGIT_DESCRIBE_OUTPUT ERROR_VARIABLE LGIT_DESCRIBE_ERROR - OUTPUT_STRIP_TRAILING_WHITESPACE) + OUTPUT_STRIP_TRAILING_WHITESPACE + ) message(STATUS "LGIT_DESCRIBE_OUTPUT:" ${LGIT_DESCRIBE_OUTPUT}) message(STATUS "LGIT_DESCRIBE_ERROR:" ${LGIT_DESCRIBE_ERROR}) # From the v[0-9]+.[0-9]+.[0-9]+ version remove the v in prefix. - string(REGEX REPLACE "^v" "" LPROJECT_RELEASE_VERSION - "${LGIT_DESCRIBE_OUTPUT}") + string( + REGEX REPLACE + "^v" + "" + LPROJECT_RELEASE_VERSION + "${LGIT_DESCRIBE_OUTPUT}" + ) # Considers the file *.release.version - set(file_release_version - "${PROJECT_SOURCE_DIR}/debian/${PROJECT_NAME}.release.version") + set( + file_release_version + "${PROJECT_SOURCE_DIR}/debian/${PROJECT_NAME}.release.version" + ) message(STATUS "file_release_version: ${file_release_version}") message(STATUS "Everything sounds great: ${LPROJECT_RELEASE_VERSION}") @@ -63,20 +74,23 @@ macro(_SETUP_DEBIAN) # Then create the containing the release version. message(STATUS "Create the release version file") file(WRITE ${file_release_version} "${LPROJECT_RELEASE_VERSION}") - endif(LPROJECT_RELEASE_VERSION STREQUAL "") - set(install_file_name_src - "debian/lib${PROJECT_NAME}${LPROJECT_RELEASE_VERSION}.install.cmake" + set( + install_file_name_src + "debian/lib${PROJECT_NAME}${LPROJECT_RELEASE_VERSION}.install.cmake" ) message(STATUS "install_file_name_src :" ${install_file_name_src}) if(EXISTS ${PROJECT_SOURCE_DIR}/${install_file_name_src}) - set(install_file_name_dest - "debian/lib${PROJECT_NAME}${LPROJECT_RELEASE_VERSION}.install") + set( + install_file_name_dest + "debian/lib${PROJECT_NAME}${LPROJECT_RELEASE_VERSION}.install" + ) execute_process( COMMAND cp ${install_file_name_src} ${install_file_name_dest} - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}) + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + ) message(STATUS "install_file_name :" ${install_file_name_dest}) file(APPEND ${install_file_name_dest} "/etc/ld.so.conf.d/*\n") @@ -85,7 +99,6 @@ macro(_SETUP_DEBIAN) file(WRITE ${install_file_name} "${CMAKE_INSTALL_PREFIX}/lib") message(STATUS "install_file_name :" ${install_file_name}) install(FILES ${install_file_name} DESTINATION /etc/ld.so.conf.d) - endif(EXISTS ${PROJECT_SOURCE_DIR}/${install_file_name_src}) endif(${PROJECT_NAME}_IS_SHARED_LIBRARY STREQUAL "SHARED_LIBRARY") endif(IS_DIRECTORY ${PROJECT_SOURCE_DIR}/debian) @@ -109,7 +122,8 @@ macro(_SETUP_PROJECT_DEB) ${PROJECT_NAME}-deb-src COMMAND git-buildpackage --git-debian-branch=debian WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - COMMENT "Generating source Debian package...") + COMMENT "Generating source Debian package..." + ) add_dependencies(deb-src ${PROJECT_NAME}-deb-src) if(NOT TARGET deb) @@ -117,10 +131,12 @@ macro(_SETUP_PROJECT_DEB) endif() add_custom_target( ${PROJECT_NAME}-deb - COMMAND git-buildpackage --git-debian-branch=debian - --git-builder="debuild -S -i.git -I.git" + COMMAND + git-buildpackage --git-debian-branch=debian + --git-builder="debuild -S -i.git -I.git" WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - COMMENT "Generating Debian package...") + COMMENT "Generating Debian package..." + ) add_dependencies(deb ${PROJECT_NAME}-deb) endif(UNIX AND NOT APPLE) endmacro(_SETUP_PROJECT_DEB) diff --git a/distcheck.cmake b/distcheck.cmake index ba9a2c0dd..f7f99a057 100644 --- a/distcheck.cmake +++ b/distcheck.cmake @@ -37,14 +37,14 @@ macro(DISTCHECK_SETUP) if(UNIX) find_program(SED sed) - set(SRCDIR - ${CMAKE_BINARY_DIR}/${PROJECT_NAME}${PROJECT_SUFFIX}-${PROJECT_VERSION}) + set( + SRCDIR + ${CMAKE_BINARY_DIR}/${PROJECT_NAME}${PROJECT_SUFFIX}-${PROJECT_VERSION} + ) set(BUILDDIR ${SRCDIR}/_build) set(INSTDIR ${SRCDIR}/_inst) set(TEST_RESULTS_DIR ${BUILDDIR}/test_results) - set(DISTCHECK_MAKEFLAGS - "" - CACHE PATH "MAKEFLAGS used for distcheck's make") + set(DISTCHECK_MAKEFLAGS "" CACHE PATH "MAKEFLAGS used for distcheck's make") # The -i argument of sed command differs according on APPLE systems if(APPLE) @@ -60,8 +60,13 @@ macro(DISTCHECK_SETUP) set(LD_LIBRARY_PATH_VARIABLE_NAME "LD_LIBRARY_PATH") endif(APPLE) - string(REPLACE "${CMAKE_SOURCE_DIR}" "${SRCDIR}" NEW_CMAKE_BINARY_DIR - "${CMAKE_BINARY_DIR}") + string( + REPLACE + "${CMAKE_SOURCE_DIR}" + "${SRCDIR}" + NEW_CMAKE_BINARY_DIR + "${CMAKE_BINARY_DIR}" + ) if(NOT TARGET distcheck) add_custom_target(distcheck COMMENT "Checking generated tarball...") @@ -76,13 +81,13 @@ macro(DISTCHECK_SETUP) mkdir -p _inst && chmod u+rwx _build _inst && chmod a-w . && cp ${CMAKE_BINARY_DIR}/CMakeCache.txt _build/ && ${SED} ${SED_I_OPTION} -e "'s|${CMAKE_SOURCE_DIR}|${SRCDIR}|g'" _build/CMakeCache.txt # Change - # previous - # source dir - # to the - # source one + # previous + # source dir + # to the + # source one && ${SED} ${SED_I_OPTION} -e "'s|${NEW_CMAKE_BINARY_DIR}|${BUILDDIR}|g'" _build/CMakeCache.txt # Change previous binary dir by the current _build - # one + # one && ${SED} ${SED_I_OPTION} -e "'s|CMAKE_CXX_COMPILER:FILEPATH=.\\+||g'" -e "'s|CMAKE_CXX_FLAGS:STRING=.\\+||g'" -e "'s|CMAKE_CXX_FLAGS_DEBUG:STRING=.\\+||g'" -e @@ -114,8 +119,8 @@ macro(DISTCHECK_SETUP) -DCMAKE_INSTALL_PREFIX=${INSTDIR} -DCATKIN_TEST_RESULTS_DIR=${TEST_RESULTS_DIR} .. || cmake .. || (echo "ERROR: the cmake configuration failed." && false) && make - ${DISTCHECK_MAKEFLAGS} || (echo "ERROR: the compilation failed." && - false) && make test || + ${DISTCHECK_MAKEFLAGS} || + (echo "ERROR: the compilation failed." && false) && make test || (echo "ERROR: the test suite failed." && false) && make install || (echo "ERROR: the install target failed." && false) && make uninstall || (echo "ERROR: the uninstall target failed." && false) && test `find @@ -131,7 +136,8 @@ macro(DISTCHECK_SETUP) "==============================================================" WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${PROJECT_NAME}${PROJECT_SUFFIX}-${PROJECT_VERSION} - COMMENT "Checking generated tarball...") + COMMENT "Checking generated tarball..." + ) add_dependencies(distcheck ${PROJECT_NAME}-distcheck) add_dependencies(${PROJECT_NAME}-distcheck ${PROJECT_NAME}-distdir) diff --git a/doxygen.cmake b/doxygen.cmake index cebab7824..79f968b2c 100644 --- a/doxygen.cmake +++ b/doxygen.cmake @@ -383,7 +383,8 @@ macro(_SETUP_DOXYGEN_CONFIG_FILE configfile) DOT_TRANSPARENT DOT_MULTI_TARGETS GENERATE_LEGEND - DOT_CLEANUP) + DOT_CLEANUP + ) if(DEFINED DOXYGEN_${option}) file(APPEND ${configfile} "${option} = ${DOXYGEN_${option}}\n") endif() @@ -410,7 +411,8 @@ macro(_SETUP_DOXYGEN_DEFAULT_OPTIONS) _set_if_undefined(DOXYGEN_PROJECT_BRIEF "\"${PROJECT_DESCRIPTION}\"") _set_if_undefined(DOXYGEN_STRIP_FROM_PATH "${PROJECT_SOURCE_DIR}") _set_if_undefined(DOXYGEN_STRIP_FROM_INC_PATH - "${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/include") + "${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/include" + ) _set_if_undefined(DOXYGEN_EXTRACT_ALL "YES") # --------------------------------------------------------------------------- # Configuration options related to warning and progress messages @@ -422,7 +424,8 @@ macro(_SETUP_DOXYGEN_DEFAULT_OPTIONS) # --------------------------------------------------------------------------- _set_if_undefined(DOXYGEN_IMAGE_PATH "${PROJECT_SOURCE_DIR}/doc") _set_if_undefined(DOXYGEN_FILE_PATTERNS - "*.cc *.cpp *.h *.hh *.hpp *.hxx *.idl") + "*.cc *.cpp *.h *.hh *.hpp *.hxx *.idl" + ) _set_if_undefined(DOXYGEN_RECURSIVE YES) # --------------------------------------------------------------------------- # Configuration options related to source browsing @@ -478,7 +481,6 @@ macro(_SETUP_DOXYGEN_DEFAULT_OPTIONS) # --------------------------------------------------------------------------- # Configuration options related to the dot tool # --------------------------------------------------------------------------- - endmacro(_SETUP_DOXYGEN_DEFAULT_OPTIONS) # _SETUP_PROJECT_DOCUMENTATION @@ -491,23 +493,24 @@ endmacro(_SETUP_DOXYGEN_DEFAULT_OPTIONS) # DOXYGEN_DOT_IMAGE_FORMAT: format for dot images. Defaults to "svg". # DOXYGEN_USE_MATHJAX: use MathJax to render LaTeX equations. Defaults to "NO". macro(_SETUP_PROJECT_DOCUMENTATION) - # Search for Doxygen. find_package(Doxygen) if(NOT DOXYGEN_FOUND) message( - STATUS "Failed to find Doxygen, documentation will not be generated.") + STATUS + "Failed to find Doxygen, documentation will not be generated." + ) else(NOT DOXYGEN_FOUND) get_directory_property(has_parent_scope PARENT_DIRECTORY) set(JRL_CMAKEMODULE_DOXYFILE_PATH "${PROJECT_BINARY_DIR}/doc/Doxyfile") if(has_parent_scope) - set(DOXYGEN_FOUND - ${DOXYGEN_FOUND} - PARENT_SCOPE) - set(JRL_CMAKEMODULE_DOXYFILE_PATH - ${JRL_CMAKEMODULE_DOXYFILE_PATH} - PARENT_SCOPE) + set(DOXYGEN_FOUND ${DOXYGEN_FOUND} PARENT_SCOPE) + set( + JRL_CMAKEMODULE_DOXYFILE_PATH + ${JRL_CMAKEMODULE_DOXYFILE_PATH} + PARENT_SCOPE + ) endif(has_parent_scope) unset(has_parent_scope) @@ -528,7 +531,8 @@ macro(_SETUP_PROJECT_DOCUMENTATION) ${PROJECT_NAME}-doc COMMAND ${DOXYGEN_EXECUTABLE} ${JRL_CMAKEMODULE_DOXYFILE_PATH} WORKING_DIRECTORY doc - COMMENT "Generating Doxygen documentation") + COMMENT "Generating Doxygen documentation" + ) else(MSVC) if(NOT TARGET doc) add_custom_target(doc COMMENT "Generating Doxygen documentation") @@ -538,11 +542,13 @@ macro(_SETUP_PROJECT_DOCUMENTATION) ${PROJECT_NAME}-doc COMMAND ${DOXYGEN_EXECUTABLE} ${JRL_CMAKEMODULE_DOXYFILE_PATH} WORKING_DIRECTORY doc - COMMENT "Generating Doxygen documentation") + COMMENT "Generating Doxygen documentation" + ) if(INSTALL_DOCUMENTATION) install( - CODE "EXECUTE_PROCESS(COMMAND ${CMAKE_MAKE_PROGRAM} ${PROJECT_NAME}-doc)" + CODE + "EXECUTE_PROCESS(COMMAND ${CMAKE_MAKE_PROGRAM} ${PROJECT_NAME}-doc)" ) endif(INSTALL_DOCUMENTATION) endif(MSVC) @@ -558,60 +564,83 @@ macro(_SETUP_PROJECT_DOCUMENTATION) ${DOXYGEN_EXECUTABLE} -w html ${PROJECT_BINARY_DIR}/doc/header.html ${PROJECT_BINARY_DIR}/doc/footer.html ${PROJECT_BINARY_DIR}/doc/doxygen.css - BYPRODUCTS ${PROJECT_BINARY_DIR}/doc/header.html - ${PROJECT_BINARY_DIR}/doc/footer.html - ${PROJECT_BINARY_DIR}/doc/doxygen.css) - add_dependencies(generate-template-css - ${PROJECT_NAME}-generate-template-css) - add_dependencies(${PROJECT_NAME}-doc - ${PROJECT_NAME}-generate-template-css) + BYPRODUCTS + ${PROJECT_BINARY_DIR}/doc/header.html + ${PROJECT_BINARY_DIR}/doc/footer.html + ${PROJECT_BINARY_DIR}/doc/doxygen.css + ) + add_dependencies( + generate-template-css + ${PROJECT_NAME}-generate-template-css + ) + add_dependencies( + ${PROJECT_NAME}-doc + ${PROJECT_NAME}-generate-template-css + ) _set_if_undefined(DOXYGEN_HTML_HEADER - "${PROJECT_BINARY_DIR}/doc/header.html") + "${PROJECT_BINARY_DIR}/doc/header.html" + ) _set_if_undefined(DOXYGEN_HTML_FOOTER - "${PROJECT_BINARY_DIR}/doc/footer.html") + "${PROJECT_BINARY_DIR}/doc/footer.html" + ) _set_if_undefined(DOXYGEN_HTML_STYLESHEET - "${PROJECT_BINARY_DIR}/doc/doxygen.css") + "${PROJECT_BINARY_DIR}/doc/doxygen.css" + ) else(DOXYGEN_USE_TEMPLATE_CSS) _set_if_undefined(DOXYGEN_HTML_FOOTER - "${PROJECT_JRL_CMAKE_MODULE_DIR}/doxygen/footer.html") + "${PROJECT_JRL_CMAKE_MODULE_DIR}/doxygen/footer.html" + ) _set_if_undefined(DOXYGEN_HTML_STYLESHEET - "${PROJECT_JRL_CMAKE_MODULE_DIR}/doxygen/doxygen.css") + "${PROJECT_JRL_CMAKE_MODULE_DIR}/doxygen/doxygen.css" + ) endif(DOXYGEN_USE_TEMPLATE_CSS) add_custom_command( - OUTPUT ${PROJECT_BINARY_DIR}/doc/${PROJECT_NAME}.doxytag - ${PROJECT_BINARY_DIR}/doc/doxygen-html + OUTPUT + ${PROJECT_BINARY_DIR}/doc/${PROJECT_NAME}.doxytag + ${PROJECT_BINARY_DIR}/doc/doxygen-html COMMAND ${DOXYGEN_EXECUTABLE} ${JRL_CMAKEMODULE_DOXYFILE_PATH} WORKING_DIRECTORY doc - COMMENT "Generating Doxygen documentation") + COMMENT "Generating Doxygen documentation" + ) # Clean generated files. set_property( DIRECTORY APPEND - PROPERTY ADDITIONAL_MAKE_CLEAN_FILES - ${PROJECT_BINARY_DIR}/doc/${PROJECT_NAME}.doxytag - ${PROJECT_BINARY_DIR}/doc/doxygen.log - ${PROJECT_BINARY_DIR}/doc/doxygen-html) + PROPERTY + ADDITIONAL_MAKE_CLEAN_FILES + ${PROJECT_BINARY_DIR}/doc/${PROJECT_NAME}.doxytag + ${PROJECT_BINARY_DIR}/doc/doxygen.log + ${PROJECT_BINARY_DIR}/doc/doxygen-html + ) # Install MathJax minimal version. if("${DOXYGEN_USE_MATHJAX}" STREQUAL "YES") - file(COPY ${PROJECT_JRL_CMAKE_MODULE_DIR}/doxygen/MathJax - DESTINATION ${PROJECT_BINARY_DIR}/doc/doxygen-html) + file( + COPY ${PROJECT_JRL_CMAKE_MODULE_DIR}/doxygen/MathJax + DESTINATION ${PROJECT_BINARY_DIR}/doc/doxygen-html + ) endif() # Install generated files. if(INSTALL_DOCUMENTATION) if(EXISTS ${PROJECT_BINARY_DIR}/doc/${PROJECT_NAME}.doxytag) - install(FILES ${PROJECT_BINARY_DIR}/doc/${PROJECT_NAME}.doxytag - DESTINATION ${CMAKE_INSTALL_DOCDIR}/doxygen-html) + install( + FILES ${PROJECT_BINARY_DIR}/doc/${PROJECT_NAME}.doxytag + DESTINATION ${CMAKE_INSTALL_DOCDIR}/doxygen-html + ) endif() - install(DIRECTORY ${PROJECT_BINARY_DIR}/doc/doxygen-html - DESTINATION ${CMAKE_INSTALL_DOCDIR}) + install( + DIRECTORY ${PROJECT_BINARY_DIR}/doc/doxygen-html + DESTINATION ${CMAKE_INSTALL_DOCDIR} + ) if(EXISTS ${PROJECT_SOURCE_DIR}/doc/pictures) - install(DIRECTORY ${PROJECT_SOURCE_DIR}/doc/pictures - DESTINATION ${CMAKE_INSTALL_DOCDIR}/doxygen-html) + install( + DIRECTORY ${PROJECT_SOURCE_DIR}/doc/pictures + DESTINATION ${CMAKE_INSTALL_DOCDIR}/doxygen-html + ) endif(EXISTS ${PROJECT_SOURCE_DIR}/doc/pictures) endif(INSTALL_DOCUMENTATION) @@ -626,7 +655,8 @@ macro(_SETUP_PROJECT_DOCUMENTATION) DOXYGEN_DOT_PATH DOXYGEN_DOT_IMAGE_FORMAT DOXYGEN_USE_MATHJAX - DOXYGEN_USE_TEMPLATE_CSS) + DOXYGEN_USE_TEMPLATE_CSS + ) endif(NOT DOXYGEN_FOUND) endmacro(_SETUP_PROJECT_DOCUMENTATION) @@ -640,9 +670,7 @@ function(REMOVE_DUPLICATES ARG_STR OUTPUT) list(REMOVE_DUPLICATES ARG_LIST) string(REGEX REPLACE "([^\\]|^);" "\\1 " _TMP_STR "${ARG_LIST}") string(REGEX REPLACE "[\\](.)" "\\1" _TMP_STR "${_TMP_STR}") # fixes escaping - set(${OUTPUT} - "${_TMP_STR}" - PARENT_SCOPE) + set(${OUTPUT} "${_TMP_STR}" PARENT_SCOPE) endfunction() # _DOXYTAG_ENTRIES_FROM_CMAKE_DEPENDENCIES @@ -653,15 +681,19 @@ endfunction() # macro(_DOXYTAG_ENTRIES_FROM_CMAKE_DEPENDENCIES DEPENDENCIES VAR_OUT) foreach(PREFIX ${DEPENDENCIES}) - if(DEFINED ${PREFIX}_DOXYGENDOCDIR - AND EXISTS ${${PREFIX}_DOXYGENDOCDIR}/${PREFIX}.doxytag) - set(${VAR_OUT} - "${${VAR_OUT}} \"${${PREFIX}_DOXYGENDOCDIR}/${PREFIX}.doxytag = ${${PREFIX}_DOXYGENDOCDIR}\"" + if( + DEFINED ${PREFIX}_DOXYGENDOCDIR + AND EXISTS ${${PREFIX}_DOXYGENDOCDIR}/${PREFIX}.doxytag + ) + set( + ${VAR_OUT} + "${${VAR_OUT}} \"${${PREFIX}_DOXYGENDOCDIR}/${PREFIX}.doxytag = ${${PREFIX}_DOXYGENDOCDIR}\"" ) endif() if(DEFINED ${PREFIX}_DEPENDENCIES) _doxytag_entries_from_cmake_dependencies("${${PREFIX}_DEPENDENCIES}" - ${VAR_OUT}) + ${VAR_OUT} + ) endif() endforeach() endmacro() @@ -682,12 +714,11 @@ macro(_SETUP_PROJECT_DOCUMENTATION_FINALIZE) find_program(DVIPS dvips DOC "DVI to PostScript converter") find_program(GS gs DOC "GhostScript interpreter") - if(NOT - (LATEX - AND GS - AND DVIPS)) + if(NOT (LATEX AND GS AND DVIPS)) message( - STATUS "Failed to find latex/dvips/gs, will use MathJax backend.") + STATUS + "Failed to find latex/dvips/gs, will use MathJax backend." + ) set(DOXYGEN_USE_MATHJAX "YES") endif() endif() @@ -701,7 +732,8 @@ macro(_SETUP_PROJECT_DOCUMENTATION_FINALIZE) endif() _set_if_undefined( DOXYGEN_HTML_HEADER - "${PROJECT_JRL_CMAKE_MODULE_DIR}/doxygen/${DOXYGEN_HEADER_NAME}") + "${PROJECT_JRL_CMAKE_MODULE_DIR}/doxygen/${DOXYGEN_HEADER_NAME}" + ) if(INSTALL_DOCUMENTATION) # Find doxytag files To ignore this list of tag files, set variable @@ -711,46 +743,65 @@ macro(_SETUP_PROJECT_DOCUMENTATION_FINALIZE) list(APPEND PKG_REQUIRES ${_PKG_CONFIG_COMPILE_TIME_REQUIRES}) foreach(PKG_CONFIG_STRING ${PKG_REQUIRES}) _parse_pkg_config_string(${PKG_CONFIG_STRING} LIBRARY_NAME PREFIX - PKG_CONFIG_STRING_NOSPACE) + PKG_CONFIG_STRING_NOSPACE + ) # If DOXYGENDOCDIR is specified, add a doc path. - if(DEFINED ${PREFIX}_DOXYGENDOCDIR - AND EXISTS ${${PREFIX}_DOXYGENDOCDIR}/${LIBRARY_NAME}.doxytag) - file(RELATIVE_PATH DEP_DOCDIR ${INSTALL_DOCDIR} - ${${PREFIX}_DOXYGENDOCDIR}) + if( + DEFINED ${PREFIX}_DOXYGENDOCDIR + AND EXISTS ${${PREFIX}_DOXYGENDOCDIR}/${LIBRARY_NAME}.doxytag + ) + file( + RELATIVE_PATH + DEP_DOCDIR + ${INSTALL_DOCDIR} + ${${PREFIX}_DOXYGENDOCDIR} + ) - set(_TAGFILES_FROM_DEPENDENCIES - "${_TAGFILES_FROM_DEPENDENCIES} \"${${PREFIX}_DOXYGENDOCDIR}/${LIBRARY_NAME}.doxytag = ${DEP_DOCDIR}\"" + set( + _TAGFILES_FROM_DEPENDENCIES + "${_TAGFILES_FROM_DEPENDENCIES} \"${${PREFIX}_DOXYGENDOCDIR}/${LIBRARY_NAME}.doxytag = ${DEP_DOCDIR}\"" ) endif() endforeach() _doxytag_entries_from_cmake_dependencies( - "${_PACKAGE_CONFIG_DEPENDENCIES_PROJECTS}" _TAGFILES_FROM_DEPENDENCIES) + "${_PACKAGE_CONFIG_DEPENDENCIES_PROJECTS}" _TAGFILES_FROM_DEPENDENCIES + ) if(_TAGFILES_FROM_DEPENDENCIES) remove_duplicates(${_TAGFILES_FROM_DEPENDENCIES} - DOXYGEN_TAGFILES_FROM_DEPENDENCIES) + DOXYGEN_TAGFILES_FROM_DEPENDENCIES + ) endif() endif() _set_if_undefined(DOXYGEN_TAGFILES "${DOXYGEN_TAGFILES_FROM_DEPENDENCIES}") if(EXISTS ${PROJECT_SOURCE_DIR}/include) - set(DOXYGEN_INCLUDE_PATH - "${DOXYGEN_INCLUDE_PATH} \"${PROJECT_SOURCE_DIR}/include\"") + set( + DOXYGEN_INCLUDE_PATH + "${DOXYGEN_INCLUDE_PATH} \"${PROJECT_SOURCE_DIR}/include\"" + ) set(DOXYGEN_INPUT "${DOXYGEN_INPUT} \"${PROJECT_SOURCE_DIR}/include\"") endif() if(EXISTS ${PROJECT_SOURCE_DIR}/src) set(DOXYGEN_INPUT "${DOXYGEN_INPUT} \"${PROJECT_SOURCE_DIR}/src\"") endif() if(EXISTS ${PROJECT_SOURCE_DIR}/tests) - set(DOXYGEN_EXAMPLE_PATH - "${DOXYGEN_EXAMPLE_PATH} \"${PROJECT_SOURCE_DIR}/tests\"") + set( + DOXYGEN_EXAMPLE_PATH + "${DOXYGEN_EXAMPLE_PATH} \"${PROJECT_SOURCE_DIR}/tests\"" + ) endif() - set(DOXYGEN_INCLUDE_PATH - "${DOXYGEN_INCLUDE_PATH} \"${PROJECT_BINARY_DIR}/include\"") + set( + DOXYGEN_INCLUDE_PATH + "${DOXYGEN_INCLUDE_PATH} \"${PROJECT_BINARY_DIR}/include\"" + ) # Generate Doxyfile and Doxyfile.extra. if(EXISTS ${PROJECT_SOURCE_DIR}/doc/Doxyfile.extra.in) - configure_file(${PROJECT_SOURCE_DIR}/doc/Doxyfile.extra.in - ${PROJECT_BINARY_DIR}/doc/Doxyfile.extra @ONLY) + configure_file( + ${PROJECT_SOURCE_DIR}/doc/Doxyfile.extra.in + ${PROJECT_BINARY_DIR}/doc/Doxyfile.extra + @ONLY + ) # Generate Doxyfile. _setup_doxygen_config_file(${JRL_CMAKEMODULE_DOXYFILE_PATH}) file(STRINGS ${PROJECT_BINARY_DIR}/doc/Doxyfile.extra doxyfile_extra) diff --git a/eigen.cmake b/eigen.cmake index 94f33b51a..93609e99b 100644 --- a/eigen.cmake +++ b/eigen.cmake @@ -26,7 +26,8 @@ macro(SEARCH_FOR_EIGEN) # ref https://github.com/jrl-umi3218/jrl-cmakemodules/issues/319 message( AUTHOR_WARNING - "SEARCH_FOR_EIGEN is deprecated and will be removed in the future") + "SEARCH_FOR_EIGEN is deprecated and will be removed in the future" + ) set(_Eigen_FOUND 0) if(${ARGC} GREATER 0) set(Eigen_REQUIRED ${ARGV0}) @@ -38,10 +39,14 @@ macro(SEARCH_FOR_EIGEN) pkg_check_modules(_Eigen ${Eigen_REQUIRED}) if(${_Eigen_FOUND}) - set(${PROJECT_NAME}_CXX_FLAGS - "${${PROJECT_NAME}_CXX_FLAGS} ${_Eigen_CFLAGS_OTHER}") - set(${PROJECT_NAME}_LINK_FLAGS - "${${PROJECT_NAME}_LINK_FLAGS} ${_Eigen_LDFLAGS_OTHER}") + set( + ${PROJECT_NAME}_CXX_FLAGS + "${${PROJECT_NAME}_CXX_FLAGS} ${_Eigen_CFLAGS_OTHER}" + ) + set( + ${PROJECT_NAME}_LINK_FLAGS + "${${PROJECT_NAME}_LINK_FLAGS} ${_Eigen_LDFLAGS_OTHER}" + ) include_directories(SYSTEM ${_Eigen_INCLUDE_DIRS}) _add_to_list(_PKG_CONFIG_REQUIRES "${Eigen_REQUIRED}" ",") @@ -51,7 +56,8 @@ macro(SEARCH_FOR_EIGEN) Eigen_INCLUDE_DIR NAMES signature_of_eigen3_matrix_library PATHS ${CMAKE_INSTALL_PREFIX}/include - PATH_SUFFIXES eigen3 eigen) + PATH_SUFFIXES eigen3 eigen + ) include_directories(SYSTEM ${Eigen_INCLUDE_DIR}) pkg_config_append_cflags(-I"${Eigen_INCLUDE_DIR}") endif() diff --git a/find-external/Accelerate/FindAccelerate.cmake b/find-external/Accelerate/FindAccelerate.cmake index 341ce8395..7109a176f 100644 --- a/find-external/Accelerate/FindAccelerate.cmake +++ b/find-external/Accelerate/FindAccelerate.cmake @@ -2,16 +2,17 @@ if(Accelerate_INCLUDES AND Accelerate_LIBRARIES) set(Accelerate_FIND_QUIETLY TRUE) endif() -find_path( - Accelerate_INCLUDES - NAMES Accelerate.h - PATHS $ENV{ACCELERATEDIR}) +find_path(Accelerate_INCLUDES NAMES Accelerate.h PATHS $ENV{ACCELERATEDIR}) find_library(Accelerate_LIBRARIES Accelerate PATHS $ENV{ACCELERATEDIR}) include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(Accelerate DEFAULT_MSG Accelerate_INCLUDES - Accelerate_LIBRARIES) +find_package_handle_standard_args( + Accelerate + DEFAULT_MSG + Accelerate_INCLUDES + Accelerate_LIBRARIES +) if(Accelerate_FOUND) get_filename_component(Accelerate_PARENTDIR ${Accelerate_INCLUDES} DIRECTORY) @@ -28,8 +29,10 @@ if(Accelerate_FOUND) add_library(Accelerate SHARED IMPORTED) set_target_properties( Accelerate - PROPERTIES IMPORTED_LOCATION "${Accelerate_LIBRARIES}" - INTERFACE_INCLUDE_DIRECTORIES "${Accelerate_INCLUDES}") + PROPERTIES + IMPORTED_LOCATION "${Accelerate_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${Accelerate_INCLUDES}" + ) endif(Accelerate_FOUND) mark_as_advanced(Accelerate_INCLUDES Accelerate_LIBRARIES) diff --git a/find-external/CDD/FindCDD.cmake b/find-external/CDD/FindCDD.cmake index 538047139..537369218 100644 --- a/find-external/CDD/FindCDD.cmake +++ b/find-external/CDD/FindCDD.cmake @@ -26,11 +26,9 @@ find_path( CDD_INCLUDE_DIR NAMES cdd.h cddmp.h PATHS ${CDD_PREFIX} - PATH_SUFFIXES include/cdd include/cddlib) -find_library( - CDD_LIBRARY - NAMES cdd - PATHS ${CDD_PREFIX}) + PATH_SUFFIXES include/cdd include/cddlib +) +find_library(CDD_LIBRARY NAMES cdd PATHS ${CDD_PREFIX}) set(CDD_LIBRARIES ${CDD_LIBRARY}) set(CDD_INCLUDE_DIRS ${CDD_INCLUDE_DIR}) @@ -41,13 +39,18 @@ mark_as_advanced(CDD_INCLUDE_DIR CDD_LIBRARY) if(CDD_FOUND AND NOT TARGET CDD::CDD) add_library(CDD::CDD SHARED IMPORTED) - set_target_properties(CDD::CDD PROPERTIES INTERFACE_INCLUDE_DIRECTORIES - "${CDD_INCLUDE_DIR}") - set_target_properties(CDD::CDD PROPERTIES IMPORTED_LOCATION_RELEASE - "${CDD_LIBRARY}") + set_target_properties( + CDD::CDD + PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CDD_INCLUDE_DIR}" + ) + set_target_properties( + CDD::CDD + PROPERTIES IMPORTED_LOCATION_RELEASE "${CDD_LIBRARY}" + ) set_property( TARGET CDD::CDD APPEND - PROPERTY IMPORTED_CONFIGURATIONS "RELEASE") + PROPERTY IMPORTED_CONFIGURATIONS "RELEASE" + ) message(STATUS "CDD found (include: ${CDD_INCLUDE_DIR}, lib: ${CDD_LIBRARY})") endif() diff --git a/find-external/CHOLMOD/FindCHOLMOD.cmake b/find-external/CHOLMOD/FindCHOLMOD.cmake index a403b88b0..3476aaa76 100644 --- a/find-external/CHOLMOD/FindCHOLMOD.cmake +++ b/find-external/CHOLMOD/FindCHOLMOD.cmake @@ -14,98 +14,119 @@ find_path( CHOLMOD_INCLUDES NAMES cholmod.h PATHS $ENV{CHOLMODDIR} ${INCLUDE_INSTALL_DIR} - PATH_SUFFIXES suitesparse ufsparse) + PATH_SUFFIXES suitesparse ufsparse +) -find_library(CHOLMOD_LIBRARIES cholmod PATHS $ENV{CHOLMODDIR} - ${LIB_INSTALL_DIR}) +find_library( + CHOLMOD_LIBRARIES + cholmod + PATHS $ENV{CHOLMODDIR} ${LIB_INSTALL_DIR} +) if(CHOLMOD_LIBRARIES) - get_filename_component(CHOLMOD_LIBDIR ${CHOLMOD_LIBRARIES} PATH) - find_library(AMD_LIBRARY amd PATHS ${CHOLMOD_LIBDIR} $ENV{CHOLMODDIR} - ${LIB_INSTALL_DIR}) + find_library( + AMD_LIBRARY + amd + PATHS ${CHOLMOD_LIBDIR} $ENV{CHOLMODDIR} ${LIB_INSTALL_DIR} + ) if(AMD_LIBRARY) list(APPEND CHOLMOD_DEPENDENCIES ${AMD_LIBRARY}) else() set(CHOLMOD_LIBRARIES FALSE) endif() - endif() if(CHOLMOD_LIBRARIES) - - find_library(COLAMD_LIBRARY colamd PATHS ${CHOLMOD_LIBDIR} $ENV{CHOLMODDIR} - ${LIB_INSTALL_DIR}) + find_library( + COLAMD_LIBRARY + colamd + PATHS ${CHOLMOD_LIBDIR} $ENV{CHOLMODDIR} ${LIB_INSTALL_DIR} + ) if(COLAMD_LIBRARY) list(APPEND CHOLMOD_DEPENDENCIES ${COLAMD_LIBRARY}) else() set(CHOLMOD_LIBRARIES FALSE) endif() - endif() if(CHOLMOD_LIBRARIES) - - find_library(CAMD_LIBRARY camd PATHS ${CHOLMOD_LIBDIR} $ENV{CHOLMODDIR} - ${LIB_INSTALL_DIR}) + find_library( + CAMD_LIBRARY + camd + PATHS ${CHOLMOD_LIBDIR} $ENV{CHOLMODDIR} ${LIB_INSTALL_DIR} + ) if(CAMD_LIBRARY) list(APPEND CHOLMOD_DEPENDENCIES ${CAMD_LIBRARY}) else() set(CHOLMOD_LIBRARIES FALSE) endif() - endif() if(CHOLMOD_LIBRARIES) - - find_library(CCOLAMD_LIBRARY ccolamd PATHS ${CHOLMOD_LIBDIR} $ENV{CHOLMODDIR} - ${LIB_INSTALL_DIR}) + find_library( + CCOLAMD_LIBRARY + ccolamd + PATHS ${CHOLMOD_LIBDIR} $ENV{CHOLMODDIR} ${LIB_INSTALL_DIR} + ) if(CCOLAMD_LIBRARY) list(APPEND CHOLMOD_DEPENDENCIES ${CCOLAMD_LIBRARY}) else() set(CHOLMOD_LIBRARIES FALSE) endif() - endif() if(CHOLMOD_LIBRARIES) - - find_library(CHOLMOD_METIS_LIBRARY metis - PATHS ${CHOLMOD_LIBDIR} $ENV{CHOLMODDIR} ${LIB_INSTALL_DIR}) + find_library( + CHOLMOD_METIS_LIBRARY + metis + PATHS ${CHOLMOD_LIBDIR} $ENV{CHOLMODDIR} ${LIB_INSTALL_DIR} + ) if(CHOLMOD_METIS_LIBRARY) list(APPEND CHOLMOD_DEPENDENCIES ${CHOLMOD_METIS_LIBRARY}) endif() - endif() if(CHOLMOD_LIBRARIES) - - find_library(SUITESPARSE_LIBRARY SuiteSparse - PATHS ${CHOLMOD_LIBDIR} $ENV{CHOLMODDIR} ${LIB_INSTALL_DIR}) + find_library( + SUITESPARSE_LIBRARY + SuiteSparse + PATHS ${CHOLMOD_LIBDIR} $ENV{CHOLMODDIR} ${LIB_INSTALL_DIR} + ) if(SUITESPARSE_LIBRARY) list(APPEND CHOLMOD_DEPENDENCIES ${SUITESPARSE_LIBRARY}) endif() - endif() include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(CHOLMOD DEFAULT_MSG CHOLMOD_INCLUDES - CHOLMOD_LIBRARIES CHOLMOD_DEPENDENCIES) +find_package_handle_standard_args( + CHOLMOD + DEFAULT_MSG + CHOLMOD_INCLUDES + CHOLMOD_LIBRARIES + CHOLMOD_DEPENDENCIES +) if(CHOLMOD_LIBRARIES AND NOT TARGET CHOLMOD::CHOLMOD) add_library(CHOLMOD::CHOLMOD SHARED IMPORTED) set_target_properties( CHOLMOD::CHOLMOD - PROPERTIES INTERFACE_LINK_LIBRARIES "${CHOLMOD_DEPENDENCIES}" - INTERFACE_INCLUDE_DIRECTORIES "${CHOLMOD_INCLUDES}" - IMPORTED_CONFIGURATIONS "RELEASE") + PROPERTIES + INTERFACE_LINK_LIBRARIES "${CHOLMOD_DEPENDENCIES}" + INTERFACE_INCLUDE_DIRECTORIES "${CHOLMOD_INCLUDES}" + IMPORTED_CONFIGURATIONS "RELEASE" + ) if(WIN32) - set_target_properties(CHOLMOD::CHOLMOD PROPERTIES IMPORTED_IMPLIB_RELEASE - "${CHOLMOD_LIBRARIES}") + set_target_properties( + CHOLMOD::CHOLMOD + PROPERTIES IMPORTED_IMPLIB_RELEASE "${CHOLMOD_LIBRARIES}" + ) else() - set_target_properties(CHOLMOD::CHOLMOD PROPERTIES IMPORTED_LOCATION_RELEASE - "${CHOLMOD_LIBRARIES}") + set_target_properties( + CHOLMOD::CHOLMOD + PROPERTIES IMPORTED_LOCATION_RELEASE "${CHOLMOD_LIBRARIES}" + ) endif() endif() @@ -118,4 +139,5 @@ mark_as_advanced( SUITESPARSE_LIBRARY CAMD_LIBRARY CCOLAMD_LIBRARY - CHOLMOD_METIS_LIBRARY) + CHOLMOD_METIS_LIBRARY +) diff --git a/find-external/CLP/FindCLP.cmake b/find-external/CLP/FindCLP.cmake index 2daee5cd2..d2e9874bf 100644 --- a/find-external/CLP/FindCLP.cmake +++ b/find-external/CLP/FindCLP.cmake @@ -22,14 +22,8 @@ # directories CLP_LIBRARIES - The libraries needed to use CLP CLP_DEFINITIONS - # Compiler switches required for using CLP -find_path( - CLP_INCLUDE_DIR - NAMES coin/ClpSimplex.hpp - PATHS ${CLP_PREFIX}) -find_library( - CLP_LIBRARY - NAMES clp Clp - PATHS ${CLP_PREFIX}) +find_path(CLP_INCLUDE_DIR NAMES coin/ClpSimplex.hpp PATHS ${CLP_PREFIX}) +find_library(CLP_LIBRARY NAMES clp Clp PATHS ${CLP_PREFIX}) set(CLP_LIBRARIES ${CLP_LIBRARY}) set(CLP_INCLUDE_DIRS ${CLP_INCLUDE_DIR}) @@ -40,13 +34,18 @@ mark_as_advanced(CLP_INCLUDE_DIR CLP_LIBRARY) if(CLP_FOUND AND NOT TARGET CLP::CLP) add_library(CLP::CLP SHARED IMPORTED) - set_target_properties(CLP::CLP PROPERTIES INTERFACE_INCLUDE_DIRECTORIES - "${CLP_INCLUDE_DIR}") - set_target_properties(CLP::CLP PROPERTIES IMPORTED_LOCATION_RELEASE - "${CLP_LIBRARY}") + set_target_properties( + CLP::CLP + PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CLP_INCLUDE_DIR}" + ) + set_target_properties( + CLP::CLP + PROPERTIES IMPORTED_LOCATION_RELEASE "${CLP_LIBRARY}" + ) set_property( TARGET CLP::CLP APPEND - PROPERTY IMPORTED_CONFIGURATIONS "RELEASE") + PROPERTY IMPORTED_CONFIGURATIONS "RELEASE" + ) message(STATUS "CLP found (include: ${CLP_INCLUDE_DIR}, lib: ${CLP_LIBRARY})") endif() diff --git a/find-external/CoinUtils/FindCoinUtils.cmake b/find-external/CoinUtils/FindCoinUtils.cmake index 154364ee0..61e383d12 100644 --- a/find-external/CoinUtils/FindCoinUtils.cmake +++ b/find-external/CoinUtils/FindCoinUtils.cmake @@ -26,35 +26,41 @@ find_path( CoinUtils_INCLUDE_DIR NAMES coin/CoinBuild.hpp - PATHS ${CoinUtils_PREFIX}) -find_library( - CoinUtils_LIBRARY - NAMES CoinUtils - PATHS ${CoinUtils_PREFIX}) + PATHS ${CoinUtils_PREFIX} +) +find_library(CoinUtils_LIBRARY NAMES CoinUtils PATHS ${CoinUtils_PREFIX}) set(CoinUtils_LIBRARIES ${CoinUtils_LIBRARY}) set(CoinUtils_INCLUDE_DIRS ${CoinUtils_INCLUDE_DIR}) include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(CoinUtils DEFAULT_MSG CoinUtils_LIBRARY - CoinUtils_INCLUDE_DIR) +find_package_handle_standard_args( + CoinUtils + DEFAULT_MSG + CoinUtils_LIBRARY + CoinUtils_INCLUDE_DIR +) mark_as_advanced(CoinUtils_INCLUDE_DIR CoinUtils_LIBRARY) if(CoinUtils_FOUND AND NOT TARGET CoinUtils::CoinUtils) add_library(CoinUtils::CoinUtils SHARED IMPORTED) set_target_properties( CoinUtils::CoinUtils - PROPERTIES INTERFACE_INCLUDE_DIRECTORIES - "${CoinUtils_INCLUDE_DIR};${CoinUtils_INCLUDE_DIR}/coin") + PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES + "${CoinUtils_INCLUDE_DIR};${CoinUtils_INCLUDE_DIR}/coin" + ) set_target_properties( - CoinUtils::CoinUtils PROPERTIES IMPORTED_LOCATION_RELEASE - "${CoinUtils_LIBRARY}") + CoinUtils::CoinUtils + PROPERTIES IMPORTED_LOCATION_RELEASE "${CoinUtils_LIBRARY}" + ) set_property( TARGET CoinUtils::CoinUtils APPEND - PROPERTY IMPORTED_CONFIGURATIONS "RELEASE") + PROPERTY IMPORTED_CONFIGURATIONS "RELEASE" + ) message( STATUS - "CoinUtils found (include: ${CoinUtils_INCLUDE_DIR}, lib: ${CoinUtils_LIBRARY})" + "CoinUtils found (include: ${CoinUtils_INCLUDE_DIR}, lib: ${CoinUtils_LIBRARY})" ) endif() diff --git a/find-external/CppAD/Findcppad.cmake b/find-external/CppAD/Findcppad.cmake index ed0eb665f..eac6d0eba 100644 --- a/find-external/CppAD/Findcppad.cmake +++ b/find-external/CppAD/Findcppad.cmake @@ -14,25 +14,35 @@ find_path( cppad_INCLUDE_DIR NAMES cppad/configure.hpp PATHS ${cppad_PREFIX} - PATH_SUFFIXES include) + PATH_SUFFIXES include +) find_library( cppad_LIBRARY NAMES cppad_lib PATHS ${cppad_PREFIX} - PATH_SUFFIXES lib) + PATH_SUFFIXES lib +) if(cppad_INCLUDE_DIR AND EXISTS "${cppad_INCLUDE_DIR}/cppad/configure.hpp") - file(STRINGS "${cppad_INCLUDE_DIR}/cppad/configure.hpp" cppad_version_str - REGEX "^# *define[\t ]+CPPAD_PACKAGE_STRING[\t ]+\"cppad-.*\"") + file( + STRINGS + "${cppad_INCLUDE_DIR}/cppad/configure.hpp" + cppad_version_str + REGEX "^# *define[\t ]+CPPAD_PACKAGE_STRING[\t ]+\"cppad-.*\"" + ) string( - REGEX - REPLACE "^# *define[\t ]+CPPAD_PACKAGE_STRING[\t ]+\"cppad-([^\"]*)\".*" - "\\1" cppad_VERSION "${cppad_version_str}") + REGEX REPLACE + "^# *define[\t ]+CPPAD_PACKAGE_STRING[\t ]+\"cppad-([^\"]*)\".*" + "\\1" + cppad_VERSION + "${cppad_version_str}" + ) endif() include(FindPackageHandleStandardArgs) find_package_handle_standard_args( cppad REQUIRED_VARS cppad_LIBRARY cppad_INCLUDE_DIR - VERSION_VAR cppad_VERSION) + VERSION_VAR cppad_VERSION +) mark_as_advanced(cppad_INCLUDE_DIR cppad_LIBRARY) diff --git a/find-external/CppAD/Findcppadcg.cmake b/find-external/CppAD/Findcppadcg.cmake index d82421d7e..c9469353f 100644 --- a/find-external/CppAD/Findcppadcg.cmake +++ b/find-external/CppAD/Findcppadcg.cmake @@ -12,21 +12,32 @@ find_path( cppadcg_INCLUDE_DIR NAMES cppad/cg.hpp PATHS ${cppadcg_PREFIX} - PATH_SUFFIXES include) + PATH_SUFFIXES include +) -if(cppadcg_INCLUDE_DIR AND EXISTS - "${cppadcg_INCLUDE_DIR}/cppad/cg/configure.hpp") - file(STRINGS "${cppadcg_INCLUDE_DIR}/cppad/cg/configure.hpp" - cppadcg_version_str - REGEX "^#define[\t ]+CPPAD_CG_VERSION[\t ]+\"cppadcg-.*\"") - string(REGEX - REPLACE "^#define[\t ]+CPPAD_CG_VERSION[\t ]+\"cppadcg-([^\"]*)\".*" - "\\1" cppadcg_VERSION "${cppadcg_version_str}") +if( + cppadcg_INCLUDE_DIR + AND EXISTS "${cppadcg_INCLUDE_DIR}/cppad/cg/configure.hpp" +) + file( + STRINGS + "${cppadcg_INCLUDE_DIR}/cppad/cg/configure.hpp" + cppadcg_version_str + REGEX "^#define[\t ]+CPPAD_CG_VERSION[\t ]+\"cppadcg-.*\"" + ) + string( + REGEX REPLACE + "^#define[\t ]+CPPAD_CG_VERSION[\t ]+\"cppadcg-([^\"]*)\".*" + "\\1" + cppadcg_VERSION + "${cppadcg_version_str}" + ) endif() include(FindPackageHandleStandardArgs) find_package_handle_standard_args( cppadcg REQUIRED_VARS cppadcg_INCLUDE_DIR - VERSION_VAR cppadcg_VERSION) + VERSION_VAR cppadcg_VERSION +) mark_as_advanced(cppadcg_INCLUDE_DIR) diff --git a/find-external/GMP/FindGMP.cmake b/find-external/GMP/FindGMP.cmake index 62eb6bd91..94eea7b70 100644 --- a/find-external/GMP/FindGMP.cmake +++ b/find-external/GMP/FindGMP.cmake @@ -5,15 +5,9 @@ if(GMP_INCLUDES AND GMP_LIBRARIES) set(GMP_FIND_QUIETLY TRUE) endif(GMP_INCLUDES AND GMP_LIBRARIES) -find_path( - GMP_INCLUDES - NAMES gmp.h - PATHS $ENV{GMPDIR} ${INCLUDE_INSTALL_DIR}) +find_path(GMP_INCLUDES NAMES gmp.h PATHS $ENV{GMPDIR} ${INCLUDE_INSTALL_DIR}) -find_library( - GMP_LIBRARIES - NAMES gmp - PATHS $ENV{GMPDIR} ${LIB_INSTALL_DIR}) +find_library(GMP_LIBRARIES NAMES gmp PATHS $ENV{GMPDIR} ${LIB_INSTALL_DIR}) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(GMP DEFAULT_MSG GMP_INCLUDES GMP_LIBRARIES) @@ -22,14 +16,21 @@ find_package_handle_standard_args(GMP DEFAULT_MSG GMP_INCLUDES GMP_LIBRARIES) if(GMP_FOUND) add_library(gmp SHARED IMPORTED) set_target_properties( - gmp PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${GMP_INCLUDE_DIR}" - IMPORTED_CONFIGURATIONS "RELEASE") + gmp + PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${GMP_INCLUDE_DIR}" + IMPORTED_CONFIGURATIONS "RELEASE" + ) if(WIN32) - set_target_properties(gmp PROPERTIES IMPORTED_IMPLIB_RELEASE - "${GMP_LIBRARIES}") + set_target_properties( + gmp + PROPERTIES IMPORTED_IMPLIB_RELEASE "${GMP_LIBRARIES}" + ) else() - set_target_properties(gmp PROPERTIES IMPORTED_LOCATION_RELEASE - "${GMP_LIBRARIES}") + set_target_properties( + gmp + PROPERTIES IMPORTED_LOCATION_RELEASE "${GMP_LIBRARIES}" + ) endif() endif() diff --git a/find-external/Ipopt/FindIpopt.cmake b/find-external/Ipopt/FindIpopt.cmake index b85636115..6ca4721c8 100644 --- a/find-external/Ipopt/FindIpopt.cmake +++ b/find-external/Ipopt/FindIpopt.cmake @@ -23,7 +23,8 @@ else() Ipopt FAIL_MESSAGE DEFAULT_MSG REQUIRED_VARS Ipopt_INCLUDE_DIRS Ipopt_LIBRARIES - VERSION_VAR Ipopt_VERSION) + VERSION_VAR Ipopt_VERSION + ) message(STATUS " Ipopt library dirs: ${Ipopt_LIBRARY_DIRS}") message(STATUS " Ipopt include dirs: ${Ipopt_INCLUDE_DIRS}") @@ -32,20 +33,28 @@ else() find_library( ipopt_lib_path NAMES ipopt ipopt-3 - PATHS ${Ipopt_LIBRARY_DIRS} REQUIRED) + PATHS ${Ipopt_LIBRARY_DIRS} + REQUIRED + ) message(STATUS " Ipopt library found at ${ipopt_lib_path}") set_target_properties( ipopt - PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${Ipopt_INCLUDE_DIRS}" - INTERFACE_COMPILE_OPTIONS "${Ipopt_CFLAGS_OTHER}" - IMPORTED_CONFIGURATIONS "RELEASE") + PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${Ipopt_INCLUDE_DIRS}" + INTERFACE_COMPILE_OPTIONS "${Ipopt_CFLAGS_OTHER}" + IMPORTED_CONFIGURATIONS "RELEASE" + ) if(WIN32) - set_target_properties(ipopt PROPERTIES IMPORTED_IMPLIB_RELEASE - "${ipopt_lib_path}") + set_target_properties( + ipopt + PROPERTIES IMPORTED_IMPLIB_RELEASE "${ipopt_lib_path}" + ) else() - set_target_properties(ipopt PROPERTIES IMPORTED_LOCATION_RELEASE - "${ipopt_lib_path}") + set_target_properties( + ipopt + PROPERTIES IMPORTED_LOCATION_RELEASE "${ipopt_lib_path}" + ) endif() add_library(Ipopt::Ipopt ALIAS ipopt) diff --git a/find-external/Julia/FindJulia.cmake b/find-external/Julia/FindJulia.cmake index 580a289a2..6da292382 100644 --- a/find-external/Julia/FindJulia.cmake +++ b/find-external/Julia/FindJulia.cmake @@ -23,17 +23,28 @@ endif() # ############################################################################## if(Julia_EXECUTABLE) - execute_process(COMMAND "${Julia_EXECUTABLE}" --startup-file=no --version - OUTPUT_VARIABLE Julia_VERSION_STRING) + execute_process( + COMMAND "${Julia_EXECUTABLE}" --startup-file=no --version + OUTPUT_VARIABLE Julia_VERSION_STRING + ) else() find_file(Julia_VERSION_INCLUDE julia_version.h PATH_SUFFIXES include/julia) file(READ ${Julia_VERSION_INCLUDE} Julia_VERSION_STRING) - string(REGEX MATCH "JULIA_VERSION_STRING.*" Julia_VERSION_STRING - ${Julia_VERSION_STRING}) + string( + REGEX MATCH + "JULIA_VERSION_STRING.*" + Julia_VERSION_STRING + ${Julia_VERSION_STRING} + ) endif() -string(REGEX REPLACE ".*([0-9]+\\.[0-9]+\\.[0-9]+).*" "\\1" - Julia_VERSION_STRING "${Julia_VERSION_STRING}") +string( + REGEX REPLACE + ".*([0-9]+\\.[0-9]+\\.[0-9]+).*" + "\\1" + Julia_VERSION_STRING + "${Julia_VERSION_STRING}" +) message(STATUS "Julia_VERSION_STRING: ${Julia_VERSION_STRING}") @@ -49,9 +60,12 @@ else() endif() if(DEFINED ENV{JULIA_INCLUDE_DIRS}) - set(Julia_INCLUDE_DIRS - $ENV{JULIA_INCLUDE_DIRS} - CACHE STRING "Location of Julia include files") + set( + Julia_INCLUDE_DIRS + $ENV{JULIA_INCLUDE_DIRS} + CACHE STRING + "Location of Julia include files" + ) elseif(Julia_EXECUTABLE) execute_process( COMMAND @@ -64,13 +78,17 @@ elseif(Julia_EXECUTABLE) julia_include_dir *= \";\" * joinpath(julia_base_dir_aux, \"src\" )\n end\n julia_include_dir" - OUTPUT_VARIABLE Julia_INCLUDE_DIRS) + OUTPUT_VARIABLE Julia_INCLUDE_DIRS + ) string(REGEX REPLACE "\"" "" Julia_INCLUDE_DIRS "${Julia_INCLUDE_DIRS}") string(REGEX REPLACE "\n" "" Julia_INCLUDE_DIRS "${Julia_INCLUDE_DIRS}") - set(Julia_INCLUDE_DIRS - ${Julia_INCLUDE_DIRS} - CACHE PATH "Location of Julia include files") + set( + Julia_INCLUDE_DIRS + ${Julia_INCLUDE_DIRS} + CACHE PATH + "Location of Julia include files" + ) elseif(Julia_PREFIX) set(Julia_INCLUDE_DIRS ${Julia_PREFIX}/include/julia) endif() @@ -90,7 +108,8 @@ if(Julia_EXECUTABLE) COMMAND ${Julia_EXECUTABLE} --startup-file=no -E "${USING_LIBDL}\nabspath(Libdl.dlpath((ccall(:jl_is_debugbuild, Cint, ()) != 0) ? \"libjulia-debug\" : \"libjulia\"))" - OUTPUT_VARIABLE Julia_LIBRARY) + OUTPUT_VARIABLE Julia_LIBRARY + ) string(REGEX REPLACE "\"" "" Julia_LIBRARY "${Julia_LIBRARY}") string(REGEX REPLACE "\n" "" Julia_LIBRARY "${Julia_LIBRARY}") @@ -103,18 +122,18 @@ if(Julia_EXECUTABLE) win_Julia_LIBRARY NAMES libjulia.dll.a PATHS "${Julia_LIBRARY_DIR}/lib" - NO_DEFAULT_PATH) + NO_DEFAULT_PATH + ) set(Julia_LIBRARY "${win_Julia_LIBRARY}") endif() - set(Julia_LIBRARY - "${Julia_LIBRARY}" - CACHE PATH "Julia library") + set(Julia_LIBRARY "${Julia_LIBRARY}" CACHE PATH "Julia library") else() find_library( Julia_LIBRARY NAMES libjulia.${Julia_VERSION_STRING}.dylib julia libjulia.dll.a libjulia - CMAKE_FIND_ROOT_PATH_BOTH) + CMAKE_FIND_ROOT_PATH_BOTH + ) endif() get_filename_component(Julia_LIBRARY_DIR ${Julia_LIBRARY} DIRECTORY) @@ -127,8 +146,10 @@ message(STATUS "Julia_LIBRARY: ${Julia_LIBRARY}") # ############################################################################## if(Julia_EXECUTABLE) - execute_process(COMMAND ${Julia_EXECUTABLE} --startup-file=no -E - "${JULIA_HOME_NAME}" OUTPUT_VARIABLE JULIA_HOME) + execute_process( + COMMAND ${Julia_EXECUTABLE} --startup-file=no -E "${JULIA_HOME_NAME}" + OUTPUT_VARIABLE JULIA_HOME + ) string(REGEX REPLACE "\"" "" JULIA_HOME "${JULIA_HOME}") string(REGEX REPLACE "\n" "" JULIA_HOME "${JULIA_HOME}") @@ -141,7 +162,8 @@ if(Julia_EXECUTABLE) execute_process( COMMAND ${Julia_EXECUTABLE} --startup-file=no -E "Base.libllvm_version" - OUTPUT_VARIABLE Julia_LLVM_VERSION) + OUTPUT_VARIABLE Julia_LLVM_VERSION + ) string(REGEX REPLACE "\"" "" Julia_LLVM_VERSION "${Julia_LLVM_VERSION}") string(REGEX REPLACE "\n" "" Julia_LLVM_VERSION "${Julia_LLVM_VERSION}") @@ -160,8 +182,10 @@ find_path(Julia_MAIN_HEADER julia.h HINTS ${Julia_INCLUDE_DIRS}) # ############################################################################## if(Julia_EXECUTABLE) - execute_process(COMMAND ${Julia_EXECUTABLE} --startup-file=no -E - "Sys.WORD_SIZE" OUTPUT_VARIABLE Julia_WORD_SIZE) + execute_process( + COMMAND ${Julia_EXECUTABLE} --startup-file=no -E "Sys.WORD_SIZE" + OUTPUT_VARIABLE Julia_WORD_SIZE + ) string(REGEX REPLACE "\n" "" Julia_WORD_SIZE "${Julia_WORD_SIZE}") message(STATUS "Julia_WORD_SIZE: ${Julia_WORD_SIZE}") endif() @@ -177,7 +201,11 @@ endif() include(FindPackageHandleStandardArgs) find_package_handle_standard_args( Julia - REQUIRED_VARS Julia_LIBRARY Julia_LIBRARY_DIR Julia_INCLUDE_DIRS - Julia_MAIN_HEADER + REQUIRED_VARS + Julia_LIBRARY + Julia_LIBRARY_DIR + Julia_INCLUDE_DIRS + Julia_MAIN_HEADER VERSION_VAR Julia_VERSION_STRING - FAIL_MESSAGE "Julia not found") + FAIL_MESSAGE "Julia not found" +) diff --git a/find-external/MPFR/FindMPFR.cmake b/find-external/MPFR/FindMPFR.cmake index 5e83a3972..c59f53e63 100644 --- a/find-external/MPFR/FindMPFR.cmake +++ b/find-external/MPFR/FindMPFR.cmake @@ -16,10 +16,7 @@ # Set MPFR_INCLUDES -find_path( - MPFR_INCLUDES - NAMES mpfr.h - PATHS $ENV{GMPDIR} ${INCLUDE_INSTALL_DIR}) +find_path(MPFR_INCLUDES NAMES mpfr.h PATHS $ENV{GMPDIR} ${INCLUDE_INSTALL_DIR}) # Set MPFR_FIND_VERSION to 1.0.0 if no minimum version is specified @@ -34,40 +31,56 @@ if(NOT MPFR_FIND_VERSION) set(MPFR_FIND_VERSION_PATCH 0) endif(NOT MPFR_FIND_VERSION_PATCH) - set(MPFR_FIND_VERSION - "${MPFR_FIND_VERSION_MAJOR}.${MPFR_FIND_VERSION_MINOR}.${MPFR_FIND_VERSION_PATCH}" + set( + MPFR_FIND_VERSION + "${MPFR_FIND_VERSION_MAJOR}.${MPFR_FIND_VERSION_MINOR}.${MPFR_FIND_VERSION_PATCH}" ) endif(NOT MPFR_FIND_VERSION) if(MPFR_INCLUDES) - # Set MPFR_VERSION file(READ "${MPFR_INCLUDES}/mpfr.h" _mpfr_version_header) - string(REGEX MATCH "define[ \t]+MPFR_VERSION_MAJOR[ \t]+([0-9]+)" - _mpfr_major_version_match "${_mpfr_version_header}") + string( + REGEX MATCH + "define[ \t]+MPFR_VERSION_MAJOR[ \t]+([0-9]+)" + _mpfr_major_version_match + "${_mpfr_version_header}" + ) set(MPFR_MAJOR_VERSION "${CMAKE_MATCH_1}") - string(REGEX MATCH "define[ \t]+MPFR_VERSION_MINOR[ \t]+([0-9]+)" - _mpfr_minor_version_match "${_mpfr_version_header}") + string( + REGEX MATCH + "define[ \t]+MPFR_VERSION_MINOR[ \t]+([0-9]+)" + _mpfr_minor_version_match + "${_mpfr_version_header}" + ) set(MPFR_MINOR_VERSION "${CMAKE_MATCH_1}") - string(REGEX MATCH "define[ \t]+MPFR_VERSION_PATCHLEVEL[ \t]+([0-9]+)" - _mpfr_patchlevel_version_match "${_mpfr_version_header}") + string( + REGEX MATCH + "define[ \t]+MPFR_VERSION_PATCHLEVEL[ \t]+([0-9]+)" + _mpfr_patchlevel_version_match + "${_mpfr_version_header}" + ) set(MPFR_PATCHLEVEL_VERSION "${CMAKE_MATCH_1}") - set(MPFR_VERSION - ${MPFR_MAJOR_VERSION}.${MPFR_MINOR_VERSION}.${MPFR_PATCHLEVEL_VERSION}) + set( + MPFR_VERSION + ${MPFR_MAJOR_VERSION}.${MPFR_MINOR_VERSION}.${MPFR_PATCHLEVEL_VERSION} + ) # Check whether found version exceeds minimum version if(${MPFR_VERSION} VERSION_LESS ${MPFR_FIND_VERSION}) set(MPFR_VERSION_OK FALSE) - message(STATUS "MPFR version ${MPFR_VERSION} found in ${MPFR_INCLUDES}, " - "but at least version ${MPFR_FIND_VERSION} is required") + message( + STATUS + "MPFR version ${MPFR_VERSION} found in ${MPFR_INCLUDES}, " + "but at least version ${MPFR_FIND_VERSION} is required" + ) else(${MPFR_VERSION} VERSION_LESS ${MPFR_FIND_VERSION}) set(MPFR_VERSION_OK TRUE) endif(${MPFR_VERSION} VERSION_LESS ${MPFR_FIND_VERSION}) - endif(MPFR_INCLUDES) # Set MPFR_LIBRARIES @@ -75,21 +88,33 @@ endif(MPFR_INCLUDES) find_library(MPFR_LIBRARIES mpfr PATHS $ENV{GMPDIR} ${LIB_INSTALL_DIR}) include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(MPFR DEFAULT_MSG MPFR_INCLUDES MPFR_LIBRARIES - MPFR_VERSION_OK) +find_package_handle_standard_args( + MPFR + DEFAULT_MSG + MPFR_INCLUDES + MPFR_LIBRARIES + MPFR_VERSION_OK +) # Set mpfr target if(MPFR_FOUND) add_library(mpfr SHARED IMPORTED) set_target_properties( - mpfr PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${MPFR_INCLUDE_DIR}" - IMPORTED_CONFIGURATIONS "RELEASE") + mpfr + PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${MPFR_INCLUDE_DIR}" + IMPORTED_CONFIGURATIONS "RELEASE" + ) if(WIN32) - set_target_properties(mpfr PROPERTIES IMPORTED_IMPLIB_RELEASE - "${MPFR_LIBRARIES}") + set_target_properties( + mpfr + PROPERTIES IMPORTED_IMPLIB_RELEASE "${MPFR_LIBRARIES}" + ) else() - set_target_properties(mpfr PROPERTIES IMPORTED_LOCATION_RELEASE - "${MPFR_LIBRARIES}") + set_target_properties( + mpfr + PROPERTIES IMPORTED_LOCATION_RELEASE "${MPFR_LIBRARIES}" + ) endif() endif() diff --git a/find-external/OpenMP/FindOpenMP.cmake b/find-external/OpenMP/FindOpenMP.cmake index 4a66db9f6..d1996d18e 100644 --- a/find-external/OpenMP/FindOpenMP.cmake +++ b/find-external/OpenMP/FindOpenMP.cmake @@ -98,21 +98,29 @@ function(_OPENMP_FLAG_CANDIDATES LANG) set(OMP_FLAG_GNU "-fopenmp") set(OMP_FLAG_LCC "-fopenmp") - set(OMP_FLAG_Clang "-fopenmp=libomp" "-fopenmp=libiomp5" "-fopenmp" - "-Xclang -fopenmp") + set( + OMP_FLAG_Clang + "-fopenmp=libomp" + "-fopenmp=libiomp5" + "-fopenmp" + "-Xclang -fopenmp" + ) set(OMP_FLAG_AppleClang "-Xclang -fopenmp") set(OMP_FLAG_HP "+Oopenmp") if(WIN32) set(OMP_FLAG_Intel "-Qopenmp") - elseif(CMAKE_${LANG}_COMPILER_ID STREQUAL "Intel" - AND "${CMAKE_${LANG}_COMPILER_VERSION}" VERSION_LESS - "15.0.0.20140528") + elseif( + CMAKE_${LANG}_COMPILER_ID STREQUAL "Intel" + AND "${CMAKE_${LANG}_COMPILER_VERSION}" VERSION_LESS "15.0.0.20140528" + ) set(OMP_FLAG_Intel "-openmp") else() set(OMP_FLAG_Intel "-qopenmp") endif() - if(CMAKE_${LANG}_COMPILER_ID STREQUAL "IntelLLVM" - AND "x${CMAKE_${LANG}_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC") + if( + CMAKE_${LANG}_COMPILER_ID STREQUAL "IntelLLVM" + AND "x${CMAKE_${LANG}_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC" + ) set(OMP_FLAG_IntelLLVM "-Qiopenmp") else() set(OMP_FLAG_IntelLLVM "-fiopenmp") @@ -138,19 +146,16 @@ function(_OPENMP_FLAG_CANDIDATES LANG) else() set(OpenMP_FLAG_CANDIDATES "-openmp" "-fopenmp" "-mp" " ") endif() - set(OpenMP_${LANG}_FLAG_CANDIDATES - "${OpenMP_FLAG_CANDIDATES}" - PARENT_SCOPE) + set(OpenMP_${LANG}_FLAG_CANDIDATES "${OpenMP_FLAG_CANDIDATES}" PARENT_SCOPE) else() - set(OpenMP_${LANG}_FLAG_CANDIDATES - "${OpenMP_${LANG}_FLAG}" - PARENT_SCOPE) + set(OpenMP_${LANG}_FLAG_CANDIDATES "${OpenMP_${LANG}_FLAG}" PARENT_SCOPE) endif() endfunction() # sample openmp source code to test -set(OpenMP_C_CXX_TEST_SOURCE - " +set( + OpenMP_C_CXX_TEST_SOURCE + " #include int main(void) { #ifdef _OPENMP @@ -162,24 +167,33 @@ int main(void) { breaks_on_purpose #endif } -") +" +) # in Fortran, an implementation may provide an omp_lib.h header or omp_lib # module, or both (OpenMP standard, section 3.1) Furthmore !$ is the Fortran # equivalent of #ifdef _OPENMP (OpenMP standard, 2.2.2) Without the conditional # compilation, some compilers (e.g. PGI) might compile OpenMP code while not # actually enabling OpenMP, building code sequentially -set(OpenMP_Fortran_TEST_SOURCE - " +set( + OpenMP_Fortran_TEST_SOURCE + " program test @OpenMP_Fortran_INCLUDE_LINE@ !$ integer :: n n = omp_get_num_threads() end program test - ") - -macro(_OPENMP_PREPARE_SOURCE LANG CONTENT_ID NAME_PREFIX FULLNAME_VAR - CONTENT_VAR) + " +) + +macro( + _OPENMP_PREPARE_SOURCE + LANG + CONTENT_ID + NAME_PREFIX + FULLNAME_VAR + CONTENT_VAR +) if("${LANG}" STREQUAL "C") set(${FULLNAME_VAR} "${NAME_PREFIX}.c") set(${CONTENT_VAR} "${OpenMP_C_CXX_${CONTENT_ID}}") @@ -197,11 +211,15 @@ include(CMakeParseImplicitLinkInfo) function(_OPENMP_GET_FLAGS LANG FLAG_MODE OPENMP_FLAG_VAR OPENMP_LIB_NAMES_VAR) _openmp_flag_candidates("${LANG}") _openmp_prepare_source("${LANG}" TEST_SOURCE OpenMPTryFlag - _OPENMP_TEST_SRC_NAME _OPENMP_TEST_SRC_CONTENT) + _OPENMP_TEST_SRC_NAME _OPENMP_TEST_SRC_CONTENT + ) unset(OpenMP_VERBOSE_COMPILE_OPTIONS) - separate_arguments(OpenMP_VERBOSE_OPTIONS NATIVE_COMMAND - "${CMAKE_${LANG}_VERBOSE_FLAG}") + separate_arguments( + OpenMP_VERBOSE_OPTIONS + NATIVE_COMMAND + "${CMAKE_${LANG}_VERBOSE_FLAG}" + ) foreach(_VERBOSE_OPTION IN LISTS OpenMP_VERBOSE_OPTIONS) if(NOT _VERBOSE_OPTION MATCHES "^-Wl,") list(APPEND OpenMP_VERBOSE_COMPILE_OPTIONS ${_VERBOSE_OPTION}) @@ -216,22 +234,24 @@ function(_OPENMP_GET_FLAGS LANG FLAG_MODE OPENMP_FLAG_VAR OPENMP_LIB_NAMES_VAR) string(REGEX REPLACE "[-/=+]" "" OPENMP_PLAIN_FLAG "${OPENMP_FLAG}") unset(_includeDirFlags) if(OpenMP_${LANG}_INCLUDE_DIR) - set(_includeDirFlags - "-DINCLUDE_DIRECTORIES:STRING=${OpenMP_${LANG}_INCLUDE_DIR}") + set( + _includeDirFlags + "-DINCLUDE_DIRECTORIES:STRING=${OpenMP_${LANG}_INCLUDE_DIR}" + ) endif() try_compile( - OpenMP_COMPILE_RESULT_${FLAG_MODE}_${OPENMP_PLAIN_FLAG} SOURCE_FROM_VAR - "${_OPENMP_TEST_SRC_NAME}" _OPENMP_TEST_SRC_CONTENT LOG_DESCRIPTION - "Detecting ${LANG} OpenMP compiler info" - CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OPENMP_FLAGS_TEST}" - ${_includeDirFlags} + OpenMP_COMPILE_RESULT_${FLAG_MODE}_${OPENMP_PLAIN_FLAG} + SOURCE_FROM_VAR "${_OPENMP_TEST_SRC_NAME}" _OPENMP_TEST_SRC_CONTENT + LOG_DESCRIPTION "Detecting ${LANG} OpenMP compiler info" + CMAKE_FLAGS + "-DCOMPILE_DEFINITIONS:STRING=${OPENMP_FLAGS_TEST}" + ${_includeDirFlags} LINK_LIBRARIES ${CMAKE_${LANG}_VERBOSE_FLAG} - OUTPUT_VARIABLE OpenMP_TRY_COMPILE_OUTPUT) + OUTPUT_VARIABLE OpenMP_TRY_COMPILE_OUTPUT + ) if(OpenMP_COMPILE_RESULT_${FLAG_MODE}_${OPENMP_PLAIN_FLAG}) - set("${OPENMP_FLAG_VAR}" - "${OPENMP_FLAG}" - PARENT_SCOPE) + set("${OPENMP_FLAG_VAR}" "${OPENMP_FLAG}" PARENT_SCOPE) if(CMAKE_${LANG}_VERBOSE_FLAG) unset(OpenMP_${LANG}_IMPLICIT_LIBRARIES) @@ -247,7 +267,8 @@ function(_OPENMP_GET_FLAGS LANG FLAG_MODE OPENMP_FLAG_VAR OPENMP_LIB_NAMES_VAR) OpenMP_${LANG}_LOG_VAR "${CMAKE_${LANG}_IMPLICIT_OBJECT_REGEX}" LANGUAGE - ${LANG}) + ${LANG} + ) # For LCC we should additionally alanyze -print-search-dirs output to # check for additional implicit_dirs. Note: This won't work if CMP0129 @@ -255,15 +276,22 @@ function(_OPENMP_GET_FLAGS LANG FLAG_MODE OPENMP_FLAG_VAR OPENMP_LIB_NAMES_VAR) if("${CMAKE_${LANG}_COMPILER_ID}" STREQUAL "LCC") execute_process( COMMAND ${CMAKE_${LANG}_COMPILER} -print-search-dirs - OUTPUT_VARIABLE output_lines COMMAND_ERROR_IS_FATAL ANY - ERROR_QUIET) + OUTPUT_VARIABLE output_lines + COMMAND_ERROR_IS_FATAL ANY + ERROR_QUIET + ) if("${output_lines}" MATCHES ".*\nlibraries:[ \t]+(.*:)\n.*") string(REPLACE ":" ";" implicit_dirs_addon "${CMAKE_MATCH_1}") - list(PREPEND OpenMP_${LANG}_IMPLICIT_LINK_DIRS - ${implicit_dirs_addon}) + list( + PREPEND + OpenMP_${LANG}_IMPLICIT_LINK_DIRS + ${implicit_dirs_addon} + ) string( - APPEND OpenMP_${LANG}_LOG_VAR - " Extended OpenMP library search paths: [${implicit_dirs}]\n") + APPEND + OpenMP_${LANG}_LOG_VAR + " Extended OpenMP library search paths: [${implicit_dirs}]\n" + ) endif() endif() @@ -274,71 +302,93 @@ function(_OPENMP_GET_FLAGS LANG FLAG_MODE OPENMP_FLAG_VAR OPENMP_LIB_NAMES_VAR) unset(_OPENMP_LIB_NAMES) foreach(_OPENMP_IMPLICIT_LIB IN LISTS OpenMP_${LANG}_IMPLICIT_LIBRARIES) - get_filename_component(_OPENMP_IMPLICIT_LIB_DIR - "${_OPENMP_IMPLICIT_LIB}" DIRECTORY) - get_filename_component(_OPENMP_IMPLICIT_LIB_NAME - "${_OPENMP_IMPLICIT_LIB}" NAME) - get_filename_component(_OPENMP_IMPLICIT_LIB_PLAIN - "${_OPENMP_IMPLICIT_LIB}" NAME_WE) + get_filename_component( + _OPENMP_IMPLICIT_LIB_DIR + "${_OPENMP_IMPLICIT_LIB}" + DIRECTORY + ) + get_filename_component( + _OPENMP_IMPLICIT_LIB_NAME + "${_OPENMP_IMPLICIT_LIB}" + NAME + ) + get_filename_component( + _OPENMP_IMPLICIT_LIB_PLAIN + "${_OPENMP_IMPLICIT_LIB}" + NAME_WE + ) string( - REGEX - REPLACE "([][+.*?()^$])" "\\\\\\1" _OPENMP_IMPLICIT_LIB_PLAIN_ESC - "${_OPENMP_IMPLICIT_LIB_PLAIN}") + REGEX REPLACE + "([][+.*?()^$])" + "\\\\\\1" + _OPENMP_IMPLICIT_LIB_PLAIN_ESC + "${_OPENMP_IMPLICIT_LIB_PLAIN}" + ) string( - REGEX - REPLACE "([][+.*?()^$])" "\\\\\\1" _OPENMP_IMPLICIT_LIB_PATH_ESC - "${_OPENMP_IMPLICIT_LIB}") - if(NOT - ( - "${_OPENMP_IMPLICIT_LIB}" IN_LIST - CMAKE_${LANG}_IMPLICIT_LINK_LIBRARIES - OR "${CMAKE_${LANG}_STANDARD_LIBRARIES}" - MATCHES - "(^| )(-Wl,)?(-l)?(${_OPENMP_IMPLICIT_LIB_PLAIN_ESC}|${_OPENMP_IMPLICIT_LIB_PATH_ESC})( |$)" - OR "${CMAKE_${LANG}_LINK_EXECUTABLE}" - MATCHES - "(^| )(-Wl,)?(-l)?(${_OPENMP_IMPLICIT_LIB_PLAIN_ESC}|${_OPENMP_IMPLICIT_LIB_PATH_ESC})( |$)" - )) + REGEX REPLACE + "([][+.*?()^$])" + "\\\\\\1" + _OPENMP_IMPLICIT_LIB_PATH_ESC + "${_OPENMP_IMPLICIT_LIB}" + ) + if( + NOT + ( + "${_OPENMP_IMPLICIT_LIB}" + IN_LIST + CMAKE_${LANG}_IMPLICIT_LINK_LIBRARIES + OR + "${CMAKE_${LANG}_STANDARD_LIBRARIES}" + MATCHES + "(^| )(-Wl,)?(-l)?(${_OPENMP_IMPLICIT_LIB_PLAIN_ESC}|${_OPENMP_IMPLICIT_LIB_PATH_ESC})( |$)" + OR + "${CMAKE_${LANG}_LINK_EXECUTABLE}" + MATCHES + "(^| )(-Wl,)?(-l)?(${_OPENMP_IMPLICIT_LIB_PLAIN_ESC}|${_OPENMP_IMPLICIT_LIB_PATH_ESC})( |$)" + ) + ) if(_OPENMP_IMPLICIT_LIB_DIR) - set(OpenMP_${_OPENMP_IMPLICIT_LIB_PLAIN}_LIBRARY - "${_OPENMP_IMPLICIT_LIB}" - CACHE - FILEPATH - "Path to the ${_OPENMP_IMPLICIT_LIB_PLAIN} library for OpenMP" + set( + OpenMP_${_OPENMP_IMPLICIT_LIB_PLAIN}_LIBRARY + "${_OPENMP_IMPLICIT_LIB}" + CACHE FILEPATH + "Path to the ${_OPENMP_IMPLICIT_LIB_PLAIN} library for OpenMP" ) else() find_library( OpenMP_${_OPENMP_IMPLICIT_LIB_PLAIN}_LIBRARY NAMES "${_OPENMP_IMPLICIT_LIB_NAME}" - DOC "Path to the ${_OPENMP_IMPLICIT_LIB_PLAIN} library for OpenMP" + DOC + "Path to the ${_OPENMP_IMPLICIT_LIB_PLAIN} library for OpenMP" HINTS ${OpenMP_${LANG}_IMPLICIT_LINK_DIRS} - CMAKE_FIND_ROOT_PATH_BOTH NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH - NO_CMAKE_ENVIRONMENT_PATH) + CMAKE_FIND_ROOT_PATH_BOTH + NO_PACKAGE_ROOT_PATH + NO_CMAKE_PATH + NO_CMAKE_ENVIRONMENT_PATH + ) endif() mark_as_advanced(OpenMP_${_OPENMP_IMPLICIT_LIB_PLAIN}_LIBRARY) list(APPEND _OPENMP_LIB_NAMES ${_OPENMP_IMPLICIT_LIB_PLAIN}) endif() endforeach() - set("${OPENMP_LIB_NAMES_VAR}" - "${_OPENMP_LIB_NAMES}" - PARENT_SCOPE) + set("${OPENMP_LIB_NAMES_VAR}" "${_OPENMP_LIB_NAMES}" PARENT_SCOPE) else() # We do not know how to extract implicit OpenMP libraries for this # compiler. Assume that it handles them automatically, e.g. the Intel # Compiler on Windows should put the dependency in its object files. - set("${OPENMP_LIB_NAMES_VAR}" - "" - PARENT_SCOPE) + set("${OPENMP_LIB_NAMES_VAR}" "" PARENT_SCOPE) endif() break() - elseif(CMAKE_${LANG}_COMPILER_ID STREQUAL "AppleClang" - AND CMAKE_${LANG}_COMPILER_VERSION VERSION_GREATER_EQUAL "7.0") - + elseif( + CMAKE_${LANG}_COMPILER_ID STREQUAL "AppleClang" + AND CMAKE_${LANG}_COMPILER_VERSION VERSION_GREATER_EQUAL "7.0" + ) # Check for separate OpenMP library on AppleClang 7+ find_library( OpenMP_libomp_LIBRARY NAMES omp gomp iomp5 - HINTS ${CMAKE_${LANG}_IMPLICIT_LINK_DIRECTORIES}) + HINTS ${CMAKE_${LANG}_IMPLICIT_LINK_DIRECTORIES} + ) mark_as_advanced(OpenMP_libomp_LIBRARY) if(OpenMP_libomp_LIBRARY) @@ -347,39 +397,40 @@ function(_OPENMP_GET_FLAGS LANG FLAG_MODE OPENMP_FLAG_VAR OPENMP_LIB_NAMES_VAR) # default header search path already. try_compile( OpenMP_COMPILE_RESULT_${FLAG_MODE}_${OPENMP_PLAIN_FLAG} - SOURCE_FROM_VAR - "${_OPENMP_TEST_SRC_NAME}" _OPENMP_TEST_SRC_CONTENT LOG_DESCRIPTION - "Trying ${LANG} OpenMP compiler with '${OpenMP_libomp_LIBRARY}'" + SOURCE_FROM_VAR "${_OPENMP_TEST_SRC_NAME}" _OPENMP_TEST_SRC_CONTENT + LOG_DESCRIPTION + "Trying ${LANG} OpenMP compiler with '${OpenMP_libomp_LIBRARY}'" CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OPENMP_FLAGS_TEST}" - LINK_LIBRARIES ${CMAKE_${LANG}_VERBOSE_FLAG} ${OpenMP_libomp_LIBRARY}) + LINK_LIBRARIES ${CMAKE_${LANG}_VERBOSE_FLAG} ${OpenMP_libomp_LIBRARY} + ) if(NOT OpenMP_COMPILE_RESULT_${FLAG_MODE}_${OPENMP_PLAIN_FLAG}) find_path(OpenMP_${LANG}_INCLUDE_DIR omp.h) mark_as_advanced(OpenMP_${LANG}_INCLUDE_DIR) - set(OpenMP_${LANG}_INCLUDE_DIR - "${OpenMP_${LANG}_INCLUDE_DIR}" - PARENT_SCOPE) + set( + OpenMP_${LANG}_INCLUDE_DIR + "${OpenMP_${LANG}_INCLUDE_DIR}" + PARENT_SCOPE + ) if(OpenMP_${LANG}_INCLUDE_DIR) try_compile( OpenMP_COMPILE_RESULT_${FLAG_MODE}_${OPENMP_PLAIN_FLAG} SOURCE_FROM_VAR - "${_OPENMP_TEST_SRC_NAME}" - _OPENMP_TEST_SRC_CONTENT + "${_OPENMP_TEST_SRC_NAME}" + _OPENMP_TEST_SRC_CONTENT LOG_DESCRIPTION - "Trying ${LANG} OpenMP compiler with '${OpenMP_libomp_LIBRARY}' and '${OpenMP_${LANG}_INCLUDE_DIR}'" + "Trying ${LANG} OpenMP compiler with '${OpenMP_libomp_LIBRARY}' and '${OpenMP_${LANG}_INCLUDE_DIR}'" CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OPENMP_FLAGS_TEST}" "-DINCLUDE_DIRECTORIES:STRING=${OpenMP_${LANG}_INCLUDE_DIR}" - LINK_LIBRARIES ${CMAKE_${LANG}_VERBOSE_FLAG} - ${OpenMP_libomp_LIBRARY}) + LINK_LIBRARIES + ${CMAKE_${LANG}_VERBOSE_FLAG} + ${OpenMP_libomp_LIBRARY} + ) endif() endif() if(OpenMP_COMPILE_RESULT_${FLAG_MODE}_${OPENMP_PLAIN_FLAG}) - set("${OPENMP_FLAG_VAR}" - "${OPENMP_FLAG}" - PARENT_SCOPE) - set("${OPENMP_LIB_NAMES_VAR}" - "libomp" - PARENT_SCOPE) + set("${OPENMP_FLAG_VAR}" "${OPENMP_FLAG}" PARENT_SCOPE) + set("${OPENMP_LIB_NAMES_VAR}" "libomp" PARENT_SCOPE) break() endif() endif() @@ -388,40 +439,35 @@ function(_OPENMP_GET_FLAGS LANG FLAG_MODE OPENMP_FLAG_VAR OPENMP_LIB_NAMES_VAR) find_library( OpenMP_libomp_LIBRARY NAMES libiomp5 libomp libgomp - HINTS ${CMAKE_${LANG}_IMPLICIT_LINK_DIRECTORIES}) + HINTS ${CMAKE_${LANG}_IMPLICIT_LINK_DIRECTORIES} + ) mark_as_advanced(OpenMP_libomp_LIBRARY) if(OpenMP_libomp_LIBRARY) try_compile( OpenMP_COMPILE_RESULT_${FLAG_MODE}_${OPENMP_PLAIN_FLAG} - SOURCE_FROM_VAR - "${_OPENMP_TEST_SRC_NAME}" _OPENMP_TEST_SRC_CONTENT LOG_DESCRIPTION - "Trying ${LANG} OpenMP compiler with '${OpenMP_libomp_LIBRARY}'" + SOURCE_FROM_VAR "${_OPENMP_TEST_SRC_NAME}" _OPENMP_TEST_SRC_CONTENT + LOG_DESCRIPTION + "Trying ${LANG} OpenMP compiler with '${OpenMP_libomp_LIBRARY}'" CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OPENMP_FLAGS_TEST}" - LINK_LIBRARIES ${CMAKE_${LANG}_VERBOSE_FLAG} ${OpenMP_libomp_LIBRARY}) + LINK_LIBRARIES ${CMAKE_${LANG}_VERBOSE_FLAG} ${OpenMP_libomp_LIBRARY} + ) if(OpenMP_COMPILE_RESULT_${FLAG_MODE}_${OPENMP_PLAIN_FLAG}) - set("${OPENMP_FLAG_VAR}" - "${OPENMP_FLAG}" - PARENT_SCOPE) - set("${OPENMP_LIB_NAMES_VAR}" - "libomp" - PARENT_SCOPE) + set("${OPENMP_FLAG_VAR}" "${OPENMP_FLAG}" PARENT_SCOPE) + set("${OPENMP_LIB_NAMES_VAR}" "libomp" PARENT_SCOPE) break() endif() endif() endif() - set("${OPENMP_LIB_NAMES_VAR}" - "NOTFOUND" - PARENT_SCOPE) - set("${OPENMP_FLAG_VAR}" - "NOTFOUND" - PARENT_SCOPE) + set("${OPENMP_LIB_NAMES_VAR}" "NOTFOUND" PARENT_SCOPE) + set("${OPENMP_FLAG_VAR}" "NOTFOUND" PARENT_SCOPE) endforeach() unset(OpenMP_VERBOSE_COMPILE_OPTIONS) endfunction() -set(OpenMP_C_CXX_CHECK_VERSION_SOURCE - " +set( + OpenMP_C_CXX_CHECK_VERSION_SOURCE + " #include #include const char ompver_str[] = { 'I', 'N', 'F', 'O', ':', 'O', 'p', 'e', 'n', 'M', @@ -438,10 +484,12 @@ int main(void) puts(ompver_str); return 0; } -") +" +) -set(OpenMP_Fortran_CHECK_VERSION_SOURCE - " +set( + OpenMP_Fortran_CHECK_VERSION_SOURCE + " program omp_ver @OpenMP_Fortran_INCLUDE_LINE@ integer, parameter :: zero = ichar('0') @@ -457,80 +505,90 @@ set(OpenMP_Fortran_CHECK_VERSION_SOURCE char(zero + mod(ompv/1, 10)), ']' /) print *, ompver_str end program omp_ver -") +" +) function(_OPENMP_GET_SPEC_DATE LANG SPEC_DATE) _openmp_prepare_source("${LANG}" CHECK_VERSION_SOURCE OpenMPCheckVersion - _OPENMP_TEST_SRC_NAME _OPENMP_TEST_SRC_CONTENT) + _OPENMP_TEST_SRC_NAME _OPENMP_TEST_SRC_CONTENT + ) unset(_includeDirFlags) if(OpenMP_${LANG}_INCLUDE_DIR) - set(_includeDirFlags - "-DINCLUDE_DIRECTORIES:STRING=${OpenMP_${LANG}_INCLUDE_DIR}") + set( + _includeDirFlags + "-DINCLUDE_DIRECTORIES:STRING=${OpenMP_${LANG}_INCLUDE_DIR}" + ) endif() - set(BIN_FILE - "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindOpenMP/ompver_${LANG}.bin" + set( + BIN_FILE + "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindOpenMP/ompver_${LANG}.bin" ) string(REGEX REPLACE "[-/=+]" "" OPENMP_PLAIN_FLAG "${OPENMP_FLAG}") try_compile( - OpenMP_SPECTEST_${LANG}_${OPENMP_PLAIN_FLAG} SOURCE_FROM_VAR - "${_OPENMP_TEST_SRC_NAME}" _OPENMP_TEST_SRC_CONTENT LOG_DESCRIPTION - "Detecting ${LANG} OpenMP version" - CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OpenMP_${LANG}_FLAGS}" - ${_includeDirFlags} - COPY_FILE "${BIN_FILE}") + OpenMP_SPECTEST_${LANG}_${OPENMP_PLAIN_FLAG} + SOURCE_FROM_VAR "${_OPENMP_TEST_SRC_NAME}" _OPENMP_TEST_SRC_CONTENT + LOG_DESCRIPTION "Detecting ${LANG} OpenMP version" + CMAKE_FLAGS + "-DCOMPILE_DEFINITIONS:STRING=${OpenMP_${LANG}_FLAGS}" + ${_includeDirFlags} + COPY_FILE "${BIN_FILE}" + ) if(${OpenMP_SPECTEST_${LANG}_${OPENMP_PLAIN_FLAG}}) - file( - STRINGS ${BIN_FILE} specstr - LIMIT_COUNT 1 - REGEX "INFO:OpenMP-date") + file(STRINGS ${BIN_FILE} specstr LIMIT_COUNT 1 REGEX "INFO:OpenMP-date") set(regex_spec_date ".*INFO:OpenMP-date\\[0*([^]]*)\\].*") if("${specstr}" MATCHES "${regex_spec_date}") - set(${SPEC_DATE} - "${CMAKE_MATCH_1}" - PARENT_SCOPE) + set(${SPEC_DATE} "${CMAKE_MATCH_1}" PARENT_SCOPE) endif() endif() endfunction() macro(_OPENMP_SET_VERSION_BY_SPEC_DATE LANG) - set(OpenMP_SPEC_DATE_MAP - # Preview versions - "201611=5.0" # OpenMP 5.0 preview 1 - # Combined versions, 2.5 onwards - "201811=5.0" - "201511=4.5" - "201307=4.0" - "201107=3.1" - "200805=3.0" - "200505=2.5" - # C/C++ version 2.0 - "200203=2.0" - # Fortran version 2.0 - "200011=2.0" - # Fortran version 1.1 - "199911=1.1" - # C/C++ version 1.0 (there's no 1.1 for C/C++) - "199810=1.0" - # Fortran version 1.0 - "199710=1.0") + set( + OpenMP_SPEC_DATE_MAP + # Preview versions + "201611=5.0" # OpenMP 5.0 preview 1 + # Combined versions, 2.5 onwards + "201811=5.0" + "201511=4.5" + "201307=4.0" + "201107=3.1" + "200805=3.0" + "200505=2.5" + # C/C++ version 2.0 + "200203=2.0" + # Fortran version 2.0 + "200011=2.0" + # Fortran version 1.1 + "199911=1.1" + # C/C++ version 1.0 (there's no 1.1 for C/C++) + "199810=1.0" + # Fortran version 1.0 + "199710=1.0" + ) if(MSVC) list(APPEND OpenMP_SPEC_DATE_MAP "2019=2.0") endif() if(OpenMP_${LANG}_SPEC_DATE) - string(REGEX MATCHALL "${OpenMP_${LANG}_SPEC_DATE}=([0-9]+)\\.([0-9]+)" - _version_match "${OpenMP_SPEC_DATE_MAP}") + string( + REGEX MATCHALL + "${OpenMP_${LANG}_SPEC_DATE}=([0-9]+)\\.([0-9]+)" + _version_match + "${OpenMP_SPEC_DATE_MAP}" + ) else() set(_version_match "") endif() if(NOT _version_match STREQUAL "") set(OpenMP_${LANG}_VERSION_MAJOR ${CMAKE_MATCH_1}) set(OpenMP_${LANG}_VERSION_MINOR ${CMAKE_MATCH_2}) - set(OpenMP_${LANG}_VERSION - "${OpenMP_${LANG}_VERSION_MAJOR}.${OpenMP_${LANG}_VERSION_MINOR}") + set( + OpenMP_${LANG}_VERSION + "${OpenMP_${LANG}_VERSION_MAJOR}.${OpenMP_${LANG}_VERSION_MINOR}" + ) else() unset(OpenMP_${LANG}_VERSION_MAJOR) unset(OpenMP_${LANG}_VERSION_MINOR) @@ -542,25 +600,38 @@ endmacro() foreach(LANG IN ITEMS C CXX) if(CMAKE_${LANG}_COMPILER_LOADED) - if(NOT DEFINED OpenMP_${LANG}_FLAGS - OR "${OpenMP_${LANG}_FLAGS}" STREQUAL "NOTFOUND" - OR NOT DEFINED OpenMP_${LANG}_LIB_NAMES - OR "${OpenMP_${LANG}_LIB_NAMES}" STREQUAL "NOTFOUND") + if( + NOT DEFINED OpenMP_${LANG}_FLAGS + OR "${OpenMP_${LANG}_FLAGS}" STREQUAL "NOTFOUND" + OR NOT DEFINED OpenMP_${LANG}_LIB_NAMES + OR "${OpenMP_${LANG}_LIB_NAMES}" STREQUAL "NOTFOUND" + ) _openmp_get_flags("${LANG}" "${LANG}" OpenMP_${LANG}_FLAGS_WORK - OpenMP_${LANG}_LIB_NAMES_WORK) - if(NOT DEFINED OpenMP_${LANG}_FLAGS OR "${OpenMP_${LANG}_FLAGS}" STREQUAL - "NOTFOUND") - set(OpenMP_${LANG}_FLAGS - "${OpenMP_${LANG}_FLAGS_WORK}" - CACHE STRING "${LANG} compiler flags for OpenMP parallelization" - FORCE) + OpenMP_${LANG}_LIB_NAMES_WORK + ) + if( + NOT DEFINED OpenMP_${LANG}_FLAGS + OR "${OpenMP_${LANG}_FLAGS}" STREQUAL "NOTFOUND" + ) + set( + OpenMP_${LANG}_FLAGS + "${OpenMP_${LANG}_FLAGS_WORK}" + CACHE STRING + "${LANG} compiler flags for OpenMP parallelization" + FORCE + ) endif() - if(NOT DEFINED OpenMP_${LANG}_LIB_NAMES OR "${OpenMP_${LANG}_LIB_NAMES}" - STREQUAL "NOTFOUND") - set(OpenMP_${LANG}_LIB_NAMES - "${OpenMP_${LANG}_LIB_NAMES_WORK}" - CACHE STRING - "${LANG} compiler libraries for OpenMP parallelization" FORCE) + if( + NOT DEFINED OpenMP_${LANG}_LIB_NAMES + OR "${OpenMP_${LANG}_LIB_NAMES}" STREQUAL "NOTFOUND" + ) + set( + OpenMP_${LANG}_LIB_NAMES + "${OpenMP_${LANG}_LIB_NAMES_WORK}" + CACHE STRING + "${LANG} compiler libraries for OpenMP parallelization" + FORCE + ) endif() mark_as_advanced(OpenMP_${LANG}_FLAGS OpenMP_${LANG}_LIB_NAMES) endif() @@ -568,64 +639,86 @@ foreach(LANG IN ITEMS C CXX) endforeach() if(CMAKE_Fortran_COMPILER_LOADED) - if(NOT DEFINED OpenMP_Fortran_FLAGS - OR "${OpenMP_Fortran_FLAGS}" STREQUAL "NOTFOUND" - OR NOT DEFINED OpenMP_Fortran_LIB_NAMES - OR "${OpenMP_Fortran_LIB_NAMES}" STREQUAL "NOTFOUND" - OR NOT DEFINED OpenMP_Fortran_HAVE_OMPLIB_MODULE) + if( + NOT DEFINED OpenMP_Fortran_FLAGS + OR "${OpenMP_Fortran_FLAGS}" STREQUAL "NOTFOUND" + OR NOT DEFINED OpenMP_Fortran_LIB_NAMES + OR "${OpenMP_Fortran_LIB_NAMES}" STREQUAL "NOTFOUND" + OR NOT DEFINED OpenMP_Fortran_HAVE_OMPLIB_MODULE + ) set(OpenMP_Fortran_INCLUDE_LINE "use omp_lib\n implicit none") _openmp_get_flags("Fortran" "FortranHeader" OpenMP_Fortran_FLAGS_WORK - OpenMP_Fortran_LIB_NAMES_WORK) + OpenMP_Fortran_LIB_NAMES_WORK + ) if(OpenMP_Fortran_FLAGS_WORK) - set(OpenMP_Fortran_HAVE_OMPLIB_MODULE - TRUE - CACHE BOOL INTERNAL "") + set(OpenMP_Fortran_HAVE_OMPLIB_MODULE TRUE CACHE BOOL INTERNAL "") endif() - if(NOT DEFINED OpenMP_Fortran_FLAGS OR "${OpenMP_Fortran_FLAGS}" STREQUAL - "NOTFOUND") - set(OpenMP_Fortran_FLAGS - "${OpenMP_Fortran_FLAGS_WORK}" - CACHE STRING "Fortran compiler flags for OpenMP parallelization" - FORCE) + if( + NOT DEFINED OpenMP_Fortran_FLAGS + OR "${OpenMP_Fortran_FLAGS}" STREQUAL "NOTFOUND" + ) + set( + OpenMP_Fortran_FLAGS + "${OpenMP_Fortran_FLAGS_WORK}" + CACHE STRING + "Fortran compiler flags for OpenMP parallelization" + FORCE + ) endif() - if(NOT DEFINED OpenMP_Fortran_LIB_NAMES OR "${OpenMP_Fortran_LIB_NAMES}" - STREQUAL "NOTFOUND") - set(OpenMP_Fortran_LIB_NAMES - "${OpenMP_Fortran_LIB_NAMES_WORK}" - CACHE STRING "Fortran compiler libraries for OpenMP parallelization" - FORCE) + if( + NOT DEFINED OpenMP_Fortran_LIB_NAMES + OR "${OpenMP_Fortran_LIB_NAMES}" STREQUAL "NOTFOUND" + ) + set( + OpenMP_Fortran_LIB_NAMES + "${OpenMP_Fortran_LIB_NAMES_WORK}" + CACHE STRING + "Fortran compiler libraries for OpenMP parallelization" + FORCE + ) endif() mark_as_advanced(OpenMP_Fortran_FLAGS OpenMP_Fortran_LIB_NAMES) endif() - if(NOT DEFINED OpenMP_Fortran_FLAGS - OR "${OpenMP_Fortran_FLAGS}" STREQUAL "NOTFOUND" - OR NOT DEFINED OpenMP_Fortran_LIB_NAMES - OR "${OpenMP_Fortran_LIB_NAMES}" STREQUAL "NOTFOUND" - OR NOT DEFINED OpenMP_Fortran_HAVE_OMPLIB_HEADER) + if( + NOT DEFINED OpenMP_Fortran_FLAGS + OR "${OpenMP_Fortran_FLAGS}" STREQUAL "NOTFOUND" + OR NOT DEFINED OpenMP_Fortran_LIB_NAMES + OR "${OpenMP_Fortran_LIB_NAMES}" STREQUAL "NOTFOUND" + OR NOT DEFINED OpenMP_Fortran_HAVE_OMPLIB_HEADER + ) set(OpenMP_Fortran_INCLUDE_LINE "implicit none\n include 'omp_lib.h'") _openmp_get_flags("Fortran" "FortranModule" OpenMP_Fortran_FLAGS_WORK - OpenMP_Fortran_LIB_NAMES_WORK) + OpenMP_Fortran_LIB_NAMES_WORK + ) if(OpenMP_Fortran_FLAGS_WORK) - set(OpenMP_Fortran_HAVE_OMPLIB_HEADER - TRUE - CACHE BOOL INTERNAL "") + set(OpenMP_Fortran_HAVE_OMPLIB_HEADER TRUE CACHE BOOL INTERNAL "") endif() - if(NOT DEFINED OpenMP_Fortran_FLAGS OR "${OpenMP_Fortran_FLAGS}" STREQUAL - "NOTFOUND") - set(OpenMP_Fortran_FLAGS - "${OpenMP_Fortran_FLAGS_WORK}" - CACHE STRING "Fortran compiler flags for OpenMP parallelization" - FORCE) + if( + NOT DEFINED OpenMP_Fortran_FLAGS + OR "${OpenMP_Fortran_FLAGS}" STREQUAL "NOTFOUND" + ) + set( + OpenMP_Fortran_FLAGS + "${OpenMP_Fortran_FLAGS_WORK}" + CACHE STRING + "Fortran compiler flags for OpenMP parallelization" + FORCE + ) endif() - if(NOT DEFINED OpenMP_Fortran_LIB_NAMES OR "${OpenMP_Fortran_LIB_NAMES}" - STREQUAL "NOTFOUND") - set(OpenMP_Fortran_LIB_NAMES - "${OpenMP_Fortran_LIB_NAMES_WORK}" - CACHE STRING "Fortran compiler libraries for OpenMP parallelization" - FORCE) + if( + NOT DEFINED OpenMP_Fortran_LIB_NAMES + OR "${OpenMP_Fortran_LIB_NAMES}" STREQUAL "NOTFOUND" + ) + set( + OpenMP_Fortran_LIB_NAMES + "${OpenMP_Fortran_LIB_NAMES_WORK}" + CACHE STRING + "Fortran compiler libraries for OpenMP parallelization" + FORCE + ) endif() endif() @@ -650,9 +743,12 @@ foreach(LANG IN LISTS OpenMP_FINDLIST) if(CMAKE_${LANG}_COMPILER_LOADED) if(NOT OpenMP_${LANG}_SPEC_DATE AND OpenMP_${LANG}_FLAGS) _openmp_get_spec_date("${LANG}" OpenMP_${LANG}_SPEC_DATE_INTERNAL) - set(OpenMP_${LANG}_SPEC_DATE - "${OpenMP_${LANG}_SPEC_DATE_INTERNAL}" - CACHE INTERNAL "${LANG} compiler's OpenMP specification date") + set( + OpenMP_${LANG}_SPEC_DATE + "${OpenMP_${LANG}_SPEC_DATE_INTERNAL}" + CACHE INTERNAL + "${LANG} compiler's OpenMP specification date" + ) endif() _openmp_set_version_by_spec_date("${LANG}") @@ -666,27 +762,37 @@ foreach(LANG IN LISTS OpenMP_FINDLIST) set(_OPENMP_${LANG}_REQUIRED_LIB_VARS OpenMP_${LANG}_LIB_NAMES) else() foreach(_OPENMP_IMPLICIT_LIB IN LISTS OpenMP_${LANG}_LIB_NAMES) - list(APPEND _OPENMP_${LANG}_REQUIRED_LIB_VARS - OpenMP_${_OPENMP_IMPLICIT_LIB}_LIBRARY) + list( + APPEND + _OPENMP_${LANG}_REQUIRED_LIB_VARS + OpenMP_${_OPENMP_IMPLICIT_LIB}_LIBRARY + ) endforeach() endif() find_package_handle_standard_args( - OpenMP_${LANG} NAME_MISMATCHED + OpenMP_${LANG} + NAME_MISMATCHED REQUIRED_VARS OpenMP_${LANG}_FLAGS ${_OPENMP_${LANG}_REQUIRED_LIB_VARS} - VERSION_VAR OpenMP_${LANG}_VERSION) + VERSION_VAR OpenMP_${LANG}_VERSION + ) if(OpenMP_${LANG}_FOUND) if(DEFINED OpenMP_${LANG}_VERSION) - if(NOT _OpenMP_MIN_VERSION OR _OpenMP_MIN_VERSION VERSION_GREATER - OpenMP_${LANG}_VERSION) + if( + NOT _OpenMP_MIN_VERSION + OR _OpenMP_MIN_VERSION VERSION_GREATER OpenMP_${LANG}_VERSION + ) set(_OpenMP_MIN_VERSION OpenMP_${LANG}_VERSION) endif() endif() set(OpenMP_${LANG}_LIBRARIES "") foreach(_OPENMP_IMPLICIT_LIB IN LISTS OpenMP_${LANG}_LIB_NAMES) - list(APPEND OpenMP_${LANG}_LIBRARIES - "${OpenMP_${_OPENMP_IMPLICIT_LIB}_LIBRARY}") + list( + APPEND + OpenMP_${LANG}_LIBRARIES + "${OpenMP_${_OPENMP_IMPLICIT_LIB}_LIBRARY}" + ) endforeach() if(OpenMP_${LANG}_INCLUDE_DIR) set(OpenMP_${LANG}_INCLUDE_DIRS ${OpenMP_${LANG}_INCLUDE_DIR}) @@ -698,30 +804,41 @@ foreach(LANG IN LISTS OpenMP_FINDLIST) add_library(OpenMP::OpenMP_${LANG} INTERFACE IMPORTED) endif() if(OpenMP_${LANG}_FLAGS) - separate_arguments(_OpenMP_${LANG}_OPTIONS NATIVE_COMMAND - "${OpenMP_${LANG}_FLAGS}") + separate_arguments( + _OpenMP_${LANG}_OPTIONS + NATIVE_COMMAND + "${OpenMP_${LANG}_FLAGS}" + ) set_property( TARGET OpenMP::OpenMP_${LANG} - PROPERTY INTERFACE_COMPILE_OPTIONS - "$<$:${_OpenMP_${LANG}_OPTIONS}>") - if(CMAKE_${LANG}_COMPILER_ID STREQUAL "Fujitsu" - OR ${CMAKE_${LANG}_COMPILER_ID} STREQUAL "IntelLLVM") + PROPERTY + INTERFACE_COMPILE_OPTIONS + "$<$:${_OpenMP_${LANG}_OPTIONS}>" + ) + if( + CMAKE_${LANG}_COMPILER_ID STREQUAL "Fujitsu" + OR ${CMAKE_${LANG}_COMPILER_ID} STREQUAL "IntelLLVM" + ) set_property( - TARGET OpenMP::OpenMP_${LANG} PROPERTY INTERFACE_LINK_OPTIONS - "${OpenMP_${LANG}_FLAGS}") + TARGET OpenMP::OpenMP_${LANG} + PROPERTY INTERFACE_LINK_OPTIONS "${OpenMP_${LANG}_FLAGS}" + ) endif() unset(_OpenMP_${LANG}_OPTIONS) endif() if(OpenMP_${LANG}_INCLUDE_DIRS) set_property( TARGET OpenMP::OpenMP_${LANG} - PROPERTY INTERFACE_INCLUDE_DIRECTORIES - "$") + PROPERTY + INTERFACE_INCLUDE_DIRECTORIES + "$" + ) endif() if(OpenMP_${LANG}_LIBRARIES) set_property( - TARGET OpenMP::OpenMP_${LANG} PROPERTY INTERFACE_LINK_LIBRARIES - "${OpenMP_${LANG}_LIBRARIES}") + TARGET OpenMP::OpenMP_${LANG} + PROPERTY INTERFACE_LINK_LIBRARIES "${OpenMP_${LANG}_LIBRARIES}" + ) endif() endif() endif() @@ -729,8 +846,10 @@ endforeach() unset(_OpenMP_REQ_VARS) foreach(LANG IN ITEMS C CXX Fortran) - if((NOT OpenMP_FIND_COMPONENTS AND CMAKE_${LANG}_COMPILER_LOADED) - OR LANG IN_LIST OpenMP_FIND_COMPONENTS) + if( + (NOT OpenMP_FIND_COMPONENTS AND CMAKE_${LANG}_COMPILER_LOADED) + OR LANG IN_LIST OpenMP_FIND_COMPONENTS + ) list(APPEND _OpenMP_REQ_VARS "OpenMP_${LANG}_FOUND") endif() endforeach() @@ -739,30 +858,32 @@ find_package_handle_standard_args( OpenMP REQUIRED_VARS ${_OpenMP_REQ_VARS} VERSION_VAR ${_OpenMP_MIN_VERSION} - HANDLE_COMPONENTS) + HANDLE_COMPONENTS +) set(OPENMP_FOUND ${OpenMP_FOUND}) if(CMAKE_Fortran_COMPILER_LOADED AND OpenMP_Fortran_FOUND) if(NOT DEFINED OpenMP_Fortran_HAVE_OMPLIB_MODULE) - set(OpenMP_Fortran_HAVE_OMPLIB_MODULE - FALSE - CACHE BOOL INTERNAL "") + set(OpenMP_Fortran_HAVE_OMPLIB_MODULE FALSE CACHE BOOL INTERNAL "") endif() if(NOT DEFINED OpenMP_Fortran_HAVE_OMPLIB_HEADER) - set(OpenMP_Fortran_HAVE_OMPLIB_HEADER - FALSE - CACHE BOOL INTERNAL "") + set(OpenMP_Fortran_HAVE_OMPLIB_HEADER FALSE CACHE BOOL INTERNAL "") endif() endif() -if(NOT - (CMAKE_C_COMPILER_LOADED - OR CMAKE_CXX_COMPILER_LOADED - OR CMAKE_Fortran_COMPILER_LOADED)) +if( + NOT + ( + CMAKE_C_COMPILER_LOADED + OR CMAKE_CXX_COMPILER_LOADED + OR CMAKE_Fortran_COMPILER_LOADED + ) +) message( SEND_ERROR - "FindOpenMP requires the C, CXX or Fortran languages to be enabled") + "FindOpenMP requires the C, CXX or Fortran languages to be enabled" + ) endif() unset(OpenMP_C_CXX_TEST_SOURCE) diff --git a/find-external/OpenRTM/FindOpenRTM.cmake b/find-external/OpenRTM/FindOpenRTM.cmake index d898b0f49..d46321366 100644 --- a/find-external/OpenRTM/FindOpenRTM.cmake +++ b/find-external/OpenRTM/FindOpenRTM.cmake @@ -15,12 +15,15 @@ if(UNIX) set(OPENRTM_CONFIG_EXECUTABLE) message( FATAL_ERROR - "rtm-config was not found in ${OPENRTM_DIR}/bin. Please set OPENRTM_DIR correctly." + "rtm-config was not found in ${OPENRTM_DIR}/bin. Please set OPENRTM_DIR correctly." ) endif() else() - find_program(OPENRTM_CONFIG_EXECUTABLE rtm-config - DOC "The location of the rtm-config script") + find_program( + OPENRTM_CONFIG_EXECUTABLE + rtm-config + DOC "The location of the rtm-config script" + ) mark_as_advanced(OPENRTM_CONFIG_EXECUTABLE) endif() @@ -31,7 +34,8 @@ if(UNIX) COMMAND ${OPENRTM_CONFIG_EXECUTABLE} --version OUTPUT_VARIABLE OPENRTM_VERSION RESULT_VARIABLE RESULT - OUTPUT_STRIP_TRAILING_WHITESPACE) + OUTPUT_STRIP_TRAILING_WHITESPACE + ) if(NOT RESULT EQUAL 0) set(OPENRTM_FOUND FALSE) @@ -41,7 +45,8 @@ if(UNIX) COMMAND ${OPENRTM_CONFIG_EXECUTABLE} --prefix OUTPUT_VARIABLE OPENRTM_DIR RESULT_VARIABLE RESULT - OUTPUT_STRIP_TRAILING_WHITESPACE) + OUTPUT_STRIP_TRAILING_WHITESPACE + ) if(RESULT EQUAL 0) if(OPENRTM_DIR) @@ -55,11 +60,16 @@ if(UNIX) execute_process( COMMAND ${OPENRTM_CONFIG_EXECUTABLE} --cflags OUTPUT_VARIABLE OPENRTM_CXX_FLAGS - RESULT_VARIABLE RESULT) + RESULT_VARIABLE RESULT + ) if(RESULT EQUAL 0) - string(REGEX MATCHALL "-D.*[^ ;]+" OPENRTM_DEFINITIONS - ${OPENRTM_CXX_FLAGS}) + string( + REGEX MATCHALL + "-D.*[^ ;]+" + OPENRTM_DEFINITIONS + ${OPENRTM_CXX_FLAGS} + ) else() set(OPENRTM_FOUND FALSE) endif() @@ -68,19 +78,28 @@ if(UNIX) COMMAND ${OPENRTM_CONFIG_EXECUTABLE} --libs OUTPUT_VARIABLE OPENRTM_LIBRARIES RESULT_VARIABLE RESULT - OUTPUT_STRIP_TRAILING_WHITESPACE) + OUTPUT_STRIP_TRAILING_WHITESPACE + ) if(RESULT EQUAL 0) - string(REGEX MATCHALL "-L[^ ;]+" OPENRTM_LIBRARY_DIRS - ${OPENRTM_LIBRARIES}) - string(REGEX REPLACE "-L" ";" OPENRTM_LIBRARY_DIRS - ${OPENRTM_LIBRARY_DIRS}) + string( + REGEX MATCHALL + "-L[^ ;]+" + OPENRTM_LIBRARY_DIRS + ${OPENRTM_LIBRARIES} + ) + string( + REGEX REPLACE + "-L" + ";" + OPENRTM_LIBRARY_DIRS + ${OPENRTM_LIBRARY_DIRS} + ) string(REGEX REPLACE "-L[^ ;]+" "" OPENRTM_LIBRARIES ${OPENRTM_LIBRARIES}) separate_arguments(OPENRTM_LIBRARIES) else() set(OPENRTM_FOUND FALSE) endif() - endif(OPENRTM_CONFIG_EXECUTABLE) set(OPENRTM_PKG_CONFIG_FILE "/usr/lib/pkgconfig/openrtm-aist.pc") if(EXISTS ${OPENRTM_PKG_CONFIG_FILE}) @@ -103,11 +122,11 @@ if(WIN32) else() set(OPENRTM_DEFAULT_VERSION ${OPENRTM_VERSION100}) endif() - set(OPENRTM_VERSION - ${OPENRTM_DEFAULT_VERSION} - CACHE - STRING - "Set version of OpenRTM-aist. Default version is ${OPENRTM_DEFAULT_VERSION}" + set( + OPENRTM_VERSION + ${OPENRTM_DEFAULT_VERSION} + CACHE STRING + "Set version of OpenRTM-aist. Default version is ${OPENRTM_DEFAULT_VERSION}" ) set(OPENRTM_INCLUDE_DIRS ${OPENRTM_DIR}) set(OPENRTM_LIBRARY_DIRS ${OPENRTM_DIR}/bin) @@ -134,9 +153,7 @@ if(WIN32) if(NOT $ENV{ACE_ROOT} STREQUAL "") set(ACE_ROOT $ENV{ACE_ROOT}) endif() - set(ACE_ROOT - ${ACE_ROOT} - CACHE PATH "The top directory of ACE") + set(ACE_ROOT ${ACE_ROOT} CACHE PATH "The top directory of ACE") endif() if(ACE_ROOT) include_directories(${ACE_ROOT}) @@ -156,15 +173,13 @@ if(NOT OPENRTM_FOUND) set(OPENRTM_DIR NOT_FOUND) endif() -set(OPENRTM_DIR - ${OPENRTM_DIR} - CACHE PATH "The top directory of OpenRTM-aist") +set(OPENRTM_DIR ${OPENRTM_DIR} CACHE PATH "The top directory of OpenRTM-aist") if(OPENRTM_FOUND) if(${OPENRTM_VERSION} MATCHES "^0\\.") message( FATAL_ERROR - "Not support OpenRTM-aist Ver.${OPENRTM_VERSION}, please install OpenRTM-aist Ver.1.0.0 or later and specify it's location." + "Not support OpenRTM-aist Ver.${OPENRTM_VERSION}, please install OpenRTM-aist Ver.1.0.0 or later and specify it's location." ) endif() @@ -183,7 +198,9 @@ else() if(NOT OpenRTM_FIND_QUIETLY) if(OpenRTM_FIND_REQUIRED) message( - FATAL_ERROR "OpenRTM-aist required, please specify it's location.") + FATAL_ERROR + "OpenRTM-aist required, please specify it's location." + ) endif() endif() endif() diff --git a/find-external/Qhull/FindQhull.cmake b/find-external/Qhull/FindQhull.cmake index ee7bd0f44..37c18d405 100644 --- a/find-external/Qhull/FindQhull.cmake +++ b/find-external/Qhull/FindQhull.cmake @@ -61,26 +61,30 @@ if(Qhull_FOUND) set_property( TARGET QHULL::QHULL APPEND - PROPERTY INTERFACE_LINK_LIBRARIES Qhull::qhull_r) + PROPERTY INTERFACE_LINK_LIBRARIES Qhull::qhull_r + ) set(QHULL_LIBRARY_TYPE SHARED) elseif(PCL_QHULL_REQUIRED_TYPE MATCHES "STATIC") set_property( TARGET QHULL::QHULL APPEND - PROPERTY INTERFACE_LINK_LIBRARIES Qhull::qhullstatic_r) + PROPERTY INTERFACE_LINK_LIBRARIES Qhull::qhullstatic_r + ) set(QHULL_LIBRARY_TYPE STATIC) else() if(PCL_SHARED_LIBS) set_property( TARGET QHULL::QHULL APPEND - PROPERTY INTERFACE_LINK_LIBRARIES Qhull::qhull_r) + PROPERTY INTERFACE_LINK_LIBRARIES Qhull::qhull_r + ) set(QHULL_LIBRARY_TYPE SHARED) else() set_property( TARGET QHULL::QHULL APPEND - PROPERTY INTERFACE_LINK_LIBRARIES Qhull::qhullstatic_r) + PROPERTY INTERFACE_LINK_LIBRARIES Qhull::qhullstatic_r + ) set(QHULL_LIBRARY_TYPE STATIC) endif() endif() @@ -88,13 +92,15 @@ if(Qhull_FOUND) set_property( TARGET QHULL::QHULL APPEND - PROPERTY INTERFACE_LINK_LIBRARIES Qhull::qhullstatic_r) + PROPERTY INTERFACE_LINK_LIBRARIES Qhull::qhullstatic_r + ) set(QHULL_LIBRARY_TYPE STATIC) else() set_property( TARGET QHULL::QHULL APPEND - PROPERTY INTERFACE_LINK_LIBRARIES Qhull::qhull_r) + PROPERTY INTERFACE_LINK_LIBRARIES Qhull::qhull_r + ) set(QHULL_LIBRARY_TYPE SHARED) endif() @@ -106,11 +112,10 @@ find_file( NAMES libqhull_r.h HINTS "${QHULL_ROOT}" "$ENV{QHULL_ROOT}" "${QHULL_INCLUDE_DIR}" PATHS "$ENV{PROGRAMFILES}/QHull" "$ENV{PROGRAMW6432}/QHull" - PATH_SUFFIXES qhull_r src/libqhull_r libqhull_r include) + PATH_SUFFIXES qhull_r src/libqhull_r libqhull_r include +) -set(QHULL_HEADER - "${QHULL_HEADER}" - CACHE INTERNAL "QHull header" FORCE) +set(QHULL_HEADER "${QHULL_HEADER}" CACHE INTERNAL "QHull header" FORCE) if(QHULL_HEADER) get_filename_component(qhull_header ${QHULL_HEADER} NAME_WE) @@ -129,28 +134,32 @@ find_library( NAMES qhull_r qhull HINTS "${QHULL_ROOT}" "$ENV{QHULL_ROOT}" PATHS "$ENV{PROGRAMFILES}/QHull" "$ENV{PROGRAMW6432}/QHull" - PATH_SUFFIXES project build bin lib) + PATH_SUFFIXES project build bin lib +) find_library( QHULL_LIBRARY_DEBUG NAMES qhull_rd qhull_d HINTS "${QHULL_ROOT}" "$ENV{QHULL_ROOT}" PATHS "$ENV{PROGRAMFILES}/QHull" "$ENV{PROGRAMW6432}/QHull" - PATH_SUFFIXES project build bin lib debug/lib) + PATH_SUFFIXES project build bin lib debug/lib +) find_library( QHULL_LIBRARY_STATIC NAMES qhullstatic_r HINTS "${QHULL_ROOT}" "$ENV{QHULL_ROOT}" PATHS "$ENV{PROGRAMFILES}/QHull" "$ENV{PROGRAMW6432}/QHull" - PATH_SUFFIXES project build bin lib) + PATH_SUFFIXES project build bin lib +) find_library( QHULL_LIBRARY_DEBUG_STATIC NAMES qhullstatic_rd HINTS "${QHULL_ROOT}" "$ENV{QHULL_ROOT}" PATHS "$ENV{PROGRAMFILES}/QHull" "$ENV{PROGRAMW6432}/QHull" - PATH_SUFFIXES project build bin lib debug/lib) + PATH_SUFFIXES project build bin lib debug/lib +) if(QHULL_LIBRARY_SHARED AND QHULL_LIBRARY_STATIC) if(PCL_QHULL_REQUIRED_TYPE MATCHES "SHARED") @@ -180,45 +189,66 @@ include(FindPackageHandleStandardArgs) find_package_handle_standard_args( Qhull FOUND_VAR QHULL_FOUND - REQUIRED_VARS QHULL_LIBRARY QHULL_INCLUDE_DIR) + REQUIRED_VARS QHULL_LIBRARY QHULL_INCLUDE_DIR +) if(QHULL_FOUND) set(HAVE_QHULL ON) add_library(QHULL::QHULL ${QHULL_LIBRARY_TYPE} IMPORTED) - set_target_properties(QHULL::QHULL PROPERTIES INTERFACE_INCLUDE_DIRECTORIES - "${QHULL_INCLUDE_DIR}") + set_target_properties( + QHULL::QHULL + PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${QHULL_INCLUDE_DIR}" + ) set_property( TARGET QHULL::QHULL APPEND - PROPERTY IMPORTED_CONFIGURATIONS "RELEASE") - set_target_properties(QHULL::QHULL - PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "CXX") - set_target_properties(QHULL::QHULL PROPERTIES INTERFACE_COMPILE_DEFINITIONS - "qh_QHpointer") + PROPERTY IMPORTED_CONFIGURATIONS "RELEASE" + ) + set_target_properties( + QHULL::QHULL + PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + ) + set_target_properties( + QHULL::QHULL + PROPERTIES INTERFACE_COMPILE_DEFINITIONS "qh_QHpointer" + ) if(MSVC) - set_target_properties(QHULL::QHULL PROPERTIES INTERFACE_COMPILE_DEFINITIONS - "qh_QHpointer_dllimport") + set_target_properties( + QHULL::QHULL + PROPERTIES INTERFACE_COMPILE_DEFINITIONS "qh_QHpointer_dllimport" + ) endif() if(WIN32 AND NOT (PCL_QHULL_REQUIRED_TYPE MATCHES "STATIC")) - set_target_properties(QHULL::QHULL PROPERTIES IMPORTED_IMPLIB_RELEASE - "${QHULL_LIBRARY}") + set_target_properties( + QHULL::QHULL + PROPERTIES IMPORTED_IMPLIB_RELEASE "${QHULL_LIBRARY}" + ) else() - set_target_properties(QHULL::QHULL PROPERTIES IMPORTED_LOCATION_RELEASE - "${QHULL_LIBRARY}") + set_target_properties( + QHULL::QHULL + PROPERTIES IMPORTED_LOCATION_RELEASE "${QHULL_LIBRARY}" + ) endif() if(QHULL_LIBRARY_DEBUG) set_property( TARGET QHULL::QHULL APPEND - PROPERTY IMPORTED_CONFIGURATIONS "DEBUG") + PROPERTY IMPORTED_CONFIGURATIONS "DEBUG" + ) if(WIN32 AND NOT (PCL_QHULL_REQUIRED_TYPE MATCHES "STATIC")) - set_target_properties(QHULL::QHULL PROPERTIES IMPORTED_IMPLIB_DEBUG - "${QHULL_LIBRARY_DEBUG}") + set_target_properties( + QHULL::QHULL + PROPERTIES IMPORTED_IMPLIB_DEBUG "${QHULL_LIBRARY_DEBUG}" + ) else() - set_target_properties(QHULL::QHULL PROPERTIES IMPORTED_LOCATION_DEBUG - "${QHULL_LIBRARY_DEBUG}") + set_target_properties( + QHULL::QHULL + PROPERTIES IMPORTED_LOCATION_DEBUG "${QHULL_LIBRARY_DEBUG}" + ) endif() endif() message( - STATUS "QHULL found (include: ${QHULL_INCLUDE_DIR}, lib: ${QHULL_LIBRARY})") + STATUS + "QHULL found (include: ${QHULL_INCLUDE_DIR}, lib: ${QHULL_LIBRARY})" + ) endif() diff --git a/find-external/Simde/FindSimde.cmake b/find-external/Simde/FindSimde.cmake index fb9a9434c..9da5e5a24 100644 --- a/find-external/Simde/FindSimde.cmake +++ b/find-external/Simde/FindSimde.cmake @@ -13,27 +13,33 @@ if(${CMAKE_VERSION} VERSION_LESS "3.16.0") find_package_handle_standard_args( Simde FOUND_VAR Simde_FOUND - REQUIRED_VARS Simde_INCLUDE_DIR) + REQUIRED_VARS Simde_INCLUDE_DIR + ) else() include(FindPackageHandleStandardArgs) find_package_handle_standard_args( Simde FOUND_VAR Simde_FOUND - REQUIRED_VARS Simde_INCLUDE_DIR REASON_FAILURE_MESSAGE - ${SIMDE_HINT_FAILURE}) + REQUIRED_VARS Simde_INCLUDE_DIR + REASON_FAILURE_MESSAGE ${SIMDE_HINT_FAILURE} + ) endif() if(Simde_FOUND) add_library(simde INTERFACE IMPORTED) - set_target_properties(simde PROPERTIES INTERFACE_INCLUDE_DIRECTORIES - "${Simde_INCLUDE_DIR}") + set_target_properties( + simde + PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${Simde_INCLUDE_DIR}" + ) endif() mark_as_advanced(SIMDE_INCLUDE_DIR) include(FeatureSummary) set_package_properties( - Simde PROPERTIES - DESCRIPTION - "Implementations of SIMD instruction sets for systems which don't natively support them." - URL "https://github.com/simd-everywhere/simde") + Simde + PROPERTIES + DESCRIPTION + "Implementations of SIMD instruction sets for systems which don't natively support them." + URL "https://github.com/simd-everywhere/simde" +) diff --git a/find-external/TinyXML/FindTinyXML.cmake b/find-external/TinyXML/FindTinyXML.cmake index fff008da4..8c0c15acb 100644 --- a/find-external/TinyXML/FindTinyXML.cmake +++ b/find-external/TinyXML/FindTinyXML.cmake @@ -26,16 +26,18 @@ find_path( TinyXML_INCLUDE_DIR NAMES tinyxml.h PATHS ${TinyXML_PREFIX} - PATH_SUFFIXES include/tinyxml) -find_library( - TinyXML_LIBRARY - NAMES tinyxml - PATHS ${TinyXML_PREFIX}) + PATH_SUFFIXES include/tinyxml +) +find_library(TinyXML_LIBRARY NAMES tinyxml PATHS ${TinyXML_PREFIX}) set(TinyXML_LIBRARIES ${TinyXML_LIBRARY}) set(TinyXML_INCLUDE_DIRS ${TinyXML_INCLUDE_DIR}) include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(TinyXML DEFAULT_MSG TinyXML_LIBRARY - TinyXML_INCLUDE_DIR) +find_package_handle_standard_args( + TinyXML + DEFAULT_MSG + TinyXML_LIBRARY + TinyXML_INCLUDE_DIR +) mark_as_advanced(TinyXML_INCLUDE_DIR TinyXML_LIBRARY) diff --git a/find-external/TinyXML/FindTinyXML2.cmake b/find-external/TinyXML/FindTinyXML2.cmake index 341b118ec..6cabaf0e3 100644 --- a/find-external/TinyXML/FindTinyXML2.cmake +++ b/find-external/TinyXML/FindTinyXML2.cmake @@ -31,36 +31,44 @@ if(TinyXML2_FOUND) if(NOT ${TINYXML_LIBRARY_LIST_LENGTH} EQUAL 4) message( FATAL_ERROR - "Unable to extract the library file path from ${TINYXML2_LIBRARY}") + "Unable to extract the library file path from ${TINYXML2_LIBRARY}" + ) endif() if(CMAKE_BUILD_TYPE MATCHES DEBUG) list(GET TINYXML2_LIBRARY 0 ASSERT_DEBUG) if(NOT ${ASSERT_DEBUG} STREQUAL "debug") message( FATAL_ERROR - "could not parse debug library path from ${TINYXML2_LIBRARY}") + "could not parse debug library path from ${TINYXML2_LIBRARY}" + ) endif() list(GET TINYXML2_LIBRARY 1 TINYXML2_LIBRARY_PATH) else() list(GET TINYXML2_LIBRARY 2 ASSERT_OPTIMIZED) if(NOT ${ASSERT_OPTIMIZED} STREQUAL "optimized") message( - FATAL_ERROR "could not parse library path from ${TINYXML2_LIBRARY}") + FATAL_ERROR + "could not parse library path from ${TINYXML2_LIBRARY}" + ) endif() list(GET TINYXML2_LIBRARY 3 TINYXML2_LIBRARY_PATH) endif() if(NOT EXISTS ${TINYXML2_LIBRARY_PATH}) message( FATAL_ERROR - "library file path ${TINYXML2_LIBRARY_PATH} does not exist") + "library file path ${TINYXML2_LIBRARY_PATH} does not exist" + ) endif() add_library(tinyxml2::tinyxml2 UNKNOWN IMPORTED) - set_property(TARGET tinyxml2::tinyxml2 PROPERTY IMPORTED_LOCATION - ${TINYXML2_LIBRARY_PATH}) set_property( - TARGET tinyxml2::tinyxml2 PROPERTY INTERFACE_INCLUDE_DIRECTORIES - ${TINYXML2_INCLUDE_DIR}) + TARGET tinyxml2::tinyxml2 + PROPERTY IMPORTED_LOCATION ${TINYXML2_LIBRARY_PATH} + ) + set_property( + TARGET tinyxml2::tinyxml2 + PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${TINYXML2_INCLUDE_DIR} + ) list(APPEND TinyXML2_TARGETS tinyxml2::tinyxml2) endif() endif() @@ -70,17 +78,25 @@ else() find_library(TINYXML2_LIBRARY tinyxml2) include(FindPackageHandleStandardArgs) - find_package_handle_standard_args(TinyXML2 DEFAULT_MSG TINYXML2_LIBRARY - TINYXML2_INCLUDE_DIR) + find_package_handle_standard_args( + TinyXML2 + DEFAULT_MSG + TINYXML2_LIBRARY + TINYXML2_INCLUDE_DIR + ) mark_as_advanced(TINYXML2_INCLUDE_DIR TINYXML2_LIBRARY) if(NOT TARGET tinyxml2::tinyxml2) add_library(tinyxml2::tinyxml2 UNKNOWN IMPORTED) - set_property(TARGET tinyxml2::tinyxml2 PROPERTY IMPORTED_LOCATION - ${TINYXML2_LIBRARY}) - set_property(TARGET tinyxml2::tinyxml2 - PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${TINYXML2_INCLUDE_DIR}) + set_property( + TARGET tinyxml2::tinyxml2 + PROPERTY IMPORTED_LOCATION ${TINYXML2_LIBRARY} + ) + set_property( + TARGET tinyxml2::tinyxml2 + PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${TINYXML2_INCLUDE_DIR} + ) list(APPEND TinyXML2_TARGETS tinyxml2::tinyxml2) endif() endif() diff --git a/find-external/assimp/Findassimp.cmake b/find-external/assimp/Findassimp.cmake index 99b834c0b..fadbfe2af 100644 --- a/find-external/assimp/Findassimp.cmake +++ b/find-external/assimp/Findassimp.cmake @@ -6,8 +6,11 @@ if(assimp_FOUND) # not defined - INTERFACE_INCLUDE_DIRECTORIES is set to a wrong path # ASSIMP_INCLUDE_DIRS and IMPORTED_LOCATION_RELEASE are well computed, so we # can redefine some target properties with them - get_target_property(_ASSIMP_INC_DIR assimp::assimp - INTERFACE_INCLUDE_DIRECTORIES) + get_target_property( + _ASSIMP_INC_DIR + assimp::assimp + INTERFACE_INCLUDE_DIRECTORIES + ) set(_ASSIMP_TARGET_OK TRUE) foreach(v ${_ASSIMP_INC_DIR}) if(NOT EXISTS ${v}) @@ -15,12 +18,17 @@ if(assimp_FOUND) endif() endforeach() if(NOT _ASSIMP_TARGET_OK) - get_target_property(_ASSIMP_IMP_LOC_RELEASE assimp::assimp - IMPORTED_LOCATION_RELEASE) + get_target_property( + _ASSIMP_IMP_LOC_RELEASE + assimp::assimp + IMPORTED_LOCATION_RELEASE + ) set_target_properties( assimp::assimp - PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${ASSIMP_INCLUDE_DIRS}" - IMPORTED_LOCATION "${_ASSIMP_IMP_LOC_RELEASE}") + PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${ASSIMP_INCLUDE_DIRS}" + IMPORTED_LOCATION "${_ASSIMP_IMP_LOC_RELEASE}" + ) endif() else() if(CMAKE_SIZEOF_VOID_P EQUAL 8) @@ -36,7 +44,8 @@ else() find_path( ASSIMP_INCLUDE_DIR NAMES assimp/anim.h - HINTS ${ASSIMP_ROOT_DIR}/include) + HINTS ${ASSIMP_ROOT_DIR}/include + ) set(assimp_INCLUDE_DIRS ${ASSIMP_INCLUDE_DIR}) if(MSVC12) @@ -46,26 +55,38 @@ else() endif(MSVC12) if(MSVC12 OR MSVC14) - foreach(ASSIMP_MSVC_VERSION ${ASSIMP_MSVC_VERSIONS}) find_path( ASSIMP_LIBRARY_DIR - NAMES assimp-${ASSIMP_MSVC_VERSION}-mt.lib - assimp-${ASSIMP_MSVC_VERSION}-mtd.lib - HINTS ${ASSIMP_ROOT_DIR}/lib${ASSIMP_ARCHITECTURE}) - - find_library(ASSIMP_LIBRARY_RELEASE assimp-${ASSIMP_MSVC_VERSION}-mt.lib - PATHS ${ASSIMP_LIBRARY_DIR}) - find_library(ASSIMP_LIBRARY_DEBUG assimp-${ASSIMP_MSVC_VERSION}-mtd.lib - PATHS ${ASSIMP_LIBRARY_DIR}) + NAMES + assimp-${ASSIMP_MSVC_VERSION}-mt.lib + assimp-${ASSIMP_MSVC_VERSION}-mtd.lib + HINTS ${ASSIMP_ROOT_DIR}/lib${ASSIMP_ARCHITECTURE} + ) + + find_library( + ASSIMP_LIBRARY_RELEASE + assimp-${ASSIMP_MSVC_VERSION}-mt.lib + PATHS ${ASSIMP_LIBRARY_DIR} + ) + find_library( + ASSIMP_LIBRARY_DEBUG + assimp-${ASSIMP_MSVC_VERSION}-mtd.lib + PATHS ${ASSIMP_LIBRARY_DIR} + ) if(NOT ASSIMP_LIBRARY_RELEASE AND NOT ASSIMP_LIBRARY_DEBUG) continue() endif() if(ASSIMP_LIBRARY_DEBUG) - set(ASSIMP_LIBRARY optimized ${ASSIMP_LIBRARY_RELEASE} debug - ${ASSIMP_LIBRARY_DEBUG}) + set( + ASSIMP_LIBRARY + optimized + ${ASSIMP_LIBRARY_RELEASE} + debug + ${ASSIMP_LIBRARY_DEBUG} + ) else() set(ASSIMP_LIBRARY optimized ${ASSIMP_LIBRARY_RELEASE}) endif() @@ -84,28 +105,33 @@ else() ${ASSIMP_ROOT_DIR}/bin${ASSIMP_ARCHITECTURE}/assimp-${ASSIMP_MSVC_VERSION}-mt.dll ${TargetDirectory}/Release/assimp-${ASSIMP_MSVC_VERSION}-mt.dll COMMENT "Copying Assimp binaries to '${TargetDirectory}'" - VERBATIM) + VERBATIM + ) endfunction(ASSIMP_COPY_BINARIES) set(assimp_LIBRARIES ${ASSIMP_LIBRARY}) endforeach() endif() - else(WIN32) - find_path( assimp_INCLUDE_DIRS - NAMES assimp/postprocess.h assimp/scene.h assimp/version.h assimp/config.h - assimp/cimport.h + NAMES + assimp/postprocess.h + assimp/scene.h + assimp/version.h + assimp/config.h + assimp/cimport.h PATHS /usr/local/include - PATHS /usr/include/) + PATHS /usr/include/ + ) find_library( assimp_LIBRARIES NAMES assimp PATHS /usr/local/lib/ PATHS /usr/lib64/ - PATHS /usr/lib/) + PATHS /usr/lib/ + ) if(assimp_INCLUDE_DIRS AND assimp_LIBRARIES) set(assimp_FOUND TRUE) @@ -120,6 +146,5 @@ else() message(FATAL_ERROR "Could not find asset importer library") endif(assimp_FIND_REQUIRED) endif(assimp_FOUND) - endif(WIN32) endif() diff --git a/find-external/glpk/Findglpk.cmake b/find-external/glpk/Findglpk.cmake index 3ab895b60..81105a024 100644 --- a/find-external/glpk/Findglpk.cmake +++ b/find-external/glpk/Findglpk.cmake @@ -22,33 +22,38 @@ # directories glpk_LIBRARIES - The libraries needed to use glpk glpk_DEFINITIONS # - Compiler switches required for using glpk -find_path( - glpk_INCLUDE_DIR - NAMES glpk.h - PATHS ${glpk_PREFIX}) -find_library( - glpk_LIBRARY - NAMES glpk - PATHS ${glpk_PREFIX}) +find_path(glpk_INCLUDE_DIR NAMES glpk.h PATHS ${glpk_PREFIX}) +find_library(glpk_LIBRARY NAMES glpk PATHS ${glpk_PREFIX}) set(glpk_LIBRARIES ${glpk_LIBRARY}) set(glpk_INCLUDE_DIRS ${glpk_INCLUDE_DIR}) include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(glpk DEFAULT_MSG glpk_LIBRARY - glpk_INCLUDE_DIR) +find_package_handle_standard_args( + glpk + DEFAULT_MSG + glpk_LIBRARY + glpk_INCLUDE_DIR +) mark_as_advanced(glpk_INCLUDE_DIR glpk_LIBRARY) if(glpk_FOUND AND NOT TARGET glpk::glpk) add_library(glpk::glpk SHARED IMPORTED) - set_target_properties(glpk::glpk PROPERTIES INTERFACE_INCLUDE_DIRECTORIES - "${glpk_INCLUDE_DIR}") - set_target_properties(glpk::glpk PROPERTIES IMPORTED_LOCATION_RELEASE - "${glpk_LIBRARY}") + set_target_properties( + glpk::glpk + PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${glpk_INCLUDE_DIR}" + ) + set_target_properties( + glpk::glpk + PROPERTIES IMPORTED_LOCATION_RELEASE "${glpk_LIBRARY}" + ) set_property( TARGET glpk::glpk APPEND - PROPERTY IMPORTED_CONFIGURATIONS "RELEASE") + PROPERTY IMPORTED_CONFIGURATIONS "RELEASE" + ) message( - STATUS "glpk found (include: ${glpk_INCLUDE_DIR}, lib: ${glpk_LIBRARY})") + STATUS + "glpk found (include: ${glpk_INCLUDE_DIR}, lib: ${glpk_LIBRARY})" + ) endif() diff --git a/find-external/qpOASES/FindqpOASES.cmake b/find-external/qpOASES/FindqpOASES.cmake index 9afa615a1..82915454f 100644 --- a/find-external/qpOASES/FindqpOASES.cmake +++ b/find-external/qpOASES/FindqpOASES.cmake @@ -25,35 +25,47 @@ find_path( qpOASES_INCLUDE_DIR NAMES qpOASES.hpp - PATHS ${qpOASES_PREFIX} ${qpOASES_PREFIX}/include) + PATHS ${qpOASES_PREFIX} ${qpOASES_PREFIX}/include +) find_library( qpOASES_LIBRARY NAMES qpOASES - PATHS ${qpOASES_PREFIX} ${qpOASES_PREFIX}/lib) + PATHS ${qpOASES_PREFIX} ${qpOASES_PREFIX}/lib +) set(qpOASES_LIBRARIES ${qpOASES_LIBRARY}) set(qpOASES_INCLUDE_DIRS ${qpOASES_INCLUDE_DIR}) include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(qpOASES DEFAULT_MSG qpOASES_LIBRARY - qpOASES_INCLUDE_DIR) +find_package_handle_standard_args( + qpOASES + DEFAULT_MSG + qpOASES_LIBRARY + qpOASES_INCLUDE_DIR +) mark_as_advanced(qpOASES_INCLUDE_DIR qpOASES_LIBRARY) if(qpOASES_FOUND AND NOT TARGET qpOASES::qpOASES) add_library(qpOASES::qpOASES SHARED IMPORTED) set_target_properties( - qpOASES::qpOASES PROPERTIES INTERFACE_INCLUDE_DIRECTORIES - "${qpOASES_INCLUDE_DIR}") - set_target_properties(qpOASES::qpOASES PROPERTIES IMPORTED_LOCATION_RELEASE - "${qpOASES_LIBRARY}") + qpOASES::qpOASES + PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${qpOASES_INCLUDE_DIR}" + ) + set_target_properties( + qpOASES::qpOASES + PROPERTIES IMPORTED_LOCATION_RELEASE "${qpOASES_LIBRARY}" + ) set_property( TARGET qpOASES::qpOASES APPEND - PROPERTY IMPORTED_CONFIGURATIONS "RELEASE") - set_target_properties(qpOASES::qpOASES - PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "CXX") + PROPERTY IMPORTED_CONFIGURATIONS "RELEASE" + ) + set_target_properties( + qpOASES::qpOASES + PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + ) message( STATUS - "qpOASES found (include: ${qpOASES_INCLUDE_DIR}, lib: ${qpOASES_LIBRARY})" + "qpOASES found (include: ${qpOASES_INCLUDE_DIR}, lib: ${qpOASES_LIBRARY})" ) endif() diff --git a/geometric-tools.cmake b/geometric-tools.cmake index c2623bef7..5357fabac 100644 --- a/geometric-tools.cmake +++ b/geometric-tools.cmake @@ -22,35 +22,49 @@ # macro(SEARCH_FOR_GEOMETRIC_TOOLS) message(STATUS "geometric-tools is required.") - set(GEOMETRIC_TOOLS_INSTALL_PREFIX - "" - CACHE PATH "geometric-tools installation prefix") + set( + GEOMETRIC_TOOLS_INSTALL_PREFIX + "" + CACHE PATH + "geometric-tools installation prefix" + ) set(LIB_GEOMETRIC_TOOLS_CORE LIB_GEOMETRIC_TOOLS_CORE-NOTFOUND) set(LIB_GEOMETRIC_TOOLS_MATH LIB_GEOMETRIC_TOOLS_MATH-NOTFOUND) message(STATUS "checking for module geometric-tools") - find_library(LIB_GEOMETRIC_TOOLS_CORE libWm5Core.so PATH - ${GEOMETRIC_TOOLS_INSTALL_PREFIX}/lib) + find_library( + LIB_GEOMETRIC_TOOLS_CORE + libWm5Core.so + PATH + ${GEOMETRIC_TOOLS_INSTALL_PREFIX}/lib + ) if(NOT LIB_GEOMETRIC_TOOLS_CORE) message( FATAL_ERROR - "Failed to find geometric-tools Core library, check that geometric-tools is installed and set the GEOMETRIC_TOOLS_INSTALL_PREFIX CMake variable." + "Failed to find geometric-tools Core library, check that geometric-tools is installed and set the GEOMETRIC_TOOLS_INSTALL_PREFIX CMake variable." ) endif() - find_library(LIB_GEOMETRIC_TOOLS_MATH libWm5Mathematics.so PATH - ${GEOMETRIC_TOOLS_INSTALL_PREFIX}/lib) + find_library( + LIB_GEOMETRIC_TOOLS_MATH + libWm5Mathematics.so + PATH + ${GEOMETRIC_TOOLS_INSTALL_PREFIX}/lib + ) if(NOT LIB_GEOMETRIC_TOOLS_MATH) message( FATAL_ERROR - "Failed to find geometric-tools Mathematics library, check that geometric-tools is installed and set the GEOMETRIC_TOOLS_INSTALL_PREFIX CMake variable." + "Failed to find geometric-tools Mathematics library, check that geometric-tools is installed and set the GEOMETRIC_TOOLS_INSTALL_PREFIX CMake variable." ) endif() set(GEOMETRIC_TOOLS_H GEOMETRIC_TOOLS-NOTFOUND) - find_path(GEOMETRIC_TOOLS_H Wm5DistSegment3Segment3.h - "${GEOMETRIC_TOOLS_INSTALL_PREFIX}/include/geometric-tools") + find_path( + GEOMETRIC_TOOLS_H + Wm5DistSegment3Segment3.h + "${GEOMETRIC_TOOLS_INSTALL_PREFIX}/include/geometric-tools" + ) if(NOT GEOMETRIC_TOOLS_H) message( FATAL_ERROR - "Failed to find geometric-tools/Wm5DistSegment3Segment3.h, check that geometric-tools is installed." + "Failed to find geometric-tools/Wm5DistSegment3Segment3.h, check that geometric-tools is installed." ) endif() @@ -58,8 +72,11 @@ macro(SEARCH_FOR_GEOMETRIC_TOOLS) set(GEOMETRIC_TOOLS_INCLUDEDIR "${GEOMETRIC_TOOLS_INSTALL_PREFIX}/include") set(GEOMETRIC_TOOLS_LIBRARYDIR "${GEOMETRIC_TOOLS_INSTALL_PREFIX}/lib") - set(GEOMETRIC_TOOLS_LIBRARIES ${LIB_GEOMETRIC_TOOLS_MATH} - ${LIB_GEOMETRIC_TOOLS_CORE}) + set( + GEOMETRIC_TOOLS_LIBRARIES + ${LIB_GEOMETRIC_TOOLS_MATH} + ${LIB_GEOMETRIC_TOOLS_CORE} + ) include_directories(SYSTEM ${GEOMETRIC_TOOLS_INCLUDEDIR}) link_directories(${GEOMETRIC_TOOLS_LIBRARYDIR}) diff --git a/gtest.cmake b/gtest.cmake index 0ddba6eec..cc3347b6d 100644 --- a/gtest.cmake +++ b/gtest.cmake @@ -13,9 +13,7 @@ # You should have received a copy of the GNU General Public License along with # this program. If not, see . -set(CURRENT_FILE_PATH - ${CMAKE_CURRENT_LIST_DIR} - CACHE INTERNAL "") +set(CURRENT_FILE_PATH ${CMAKE_CURRENT_LIST_DIR} CACHE INTERNAL "") # .rst: .. command:: ADD_GTEST_SUITE([GIT_TAG]) # @@ -35,34 +33,38 @@ macro(ADD_GTEST_SUITE) list(GET extra_macro_args 0 GTEST_GIT_TAG) endif() # Download and unpack googletest at configure time - configure_file(${CURRENT_FILE_PATH}/gtest/CMakeLists.txt.in - gtest/CMakeLists.txt) + configure_file( + ${CURRENT_FILE_PATH}/gtest/CMakeLists.txt.in + gtest/CMakeLists.txt + ) execute_process( COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . RESULT_VARIABLE result - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/gtest) + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/gtest + ) if(result) message(FATAL_ERROR "CMake step for googletest failed: ${result}") endif() execute_process( COMMAND ${CMAKE_COMMAND} --build . RESULT_VARIABLE result - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/gtest) + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/gtest + ) if(result) message(FATAL_ERROR "Build step for googletest failed: ${result}") endif() # Prevent overriding the parent project's compiler/linker settings on Windows - set(gtest_force_shared_crt - ON - CACHE BOOL "" FORCE) + set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) # Add googletest directly to our build. This defines the gtest and gtest_main # targets. - add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/gtest/src - ${CMAKE_CURRENT_BINARY_DIR}/gtest/build EXCLUDE_FROM_ALL) + add_subdirectory( + ${CMAKE_CURRENT_BINARY_DIR}/gtest/src + ${CMAKE_CURRENT_BINARY_DIR}/gtest/build + EXCLUDE_FROM_ALL + ) # Force the include directories to be silent with respect to warnings. include_directories(SYSTEM "${gtest_SOURCE_DIR}/include") - endmacro(ADD_GTEST_SUITE) diff --git a/hpp.cmake b/hpp.cmake index f0381853c..369a61973 100644 --- a/hpp.cmake +++ b/hpp.cmake @@ -65,16 +65,12 @@ include(${CMAKE_CURRENT_LIST_DIR}/base.cmake) include(${CMAKE_CURRENT_LIST_DIR}/hpp/doc.cmake) # Activate hpp-util logging if requested -set(HPP_DEBUG - FALSE - CACHE BOOL "trigger hpp-util debug output") +set(HPP_DEBUG FALSE CACHE BOOL "trigger hpp-util debug output") if(HPP_DEBUG) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHPP_DEBUG") endif() # Activate hpp-util logging if requested -set(HPP_BENCHMARK - FALSE - CACHE BOOL "trigger hpp-util benchmark output") +set(HPP_BENCHMARK FALSE CACHE BOOL "trigger hpp-util benchmark output") if(HPP_BENCHMARK) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHPP_ENABLE_BENCHMARK") endif() diff --git a/ide.cmake b/ide.cmake index e1f4dc1e5..a29a159ee 100644 --- a/ide.cmake +++ b/ide.cmake @@ -23,17 +23,13 @@ function(LARGEST_COMMON_PREFIX a b prefix) set(len ${len_b}) endif() - set(${prefix} - "" - PARENT_SCOPE) + set(${prefix} "" PARENT_SCOPE) foreach(size RANGE 1 ${len}) string(SUBSTRING ${a} 0 ${size} sub_a) string(SUBSTRING ${b} 0 ${size} sub_b) if(${sub_a} STREQUAL ${sub_b}) - set(${prefix} - ${sub_a} - PARENT_SCOPE) + set(${prefix} ${sub_a} PARENT_SCOPE) else() break() endif() @@ -45,10 +41,20 @@ function(ADD_GROUP GROUP_NAME FILENAMES) foreach(filename ${${FILENAMES}}) get_filename_component(filenamePath ${filename} PATH) get_filename_component(filenameName ${filename} NAME) - string(REGEX REPLACE "${PROJECT_BINARY_DIR}/" "" filenamePath - "${filenamePath}/") - string(REGEX REPLACE "${PROJECT_SOURCE_DIR}/" "" filenamePath - "${filenamePath}/") + string( + REGEX REPLACE + "${PROJECT_BINARY_DIR}/" + "" + filenamePath + "${filenamePath}/" + ) + string( + REGEX REPLACE + "${PROJECT_SOURCE_DIR}/" + "" + filenamePath + "${filenamePath}/" + ) string(REGEX REPLACE "//" "/" filenamePath ${filenamePath}) list(APPEND REDUCED_FILENAMES ${filenamePath}) endforeach() diff --git a/idl.cmake b/idl.cmake index 4698a2fbe..1c109d7bb 100644 --- a/idl.cmake +++ b/idl.cmake @@ -59,8 +59,13 @@ macro(GENERATE_IDL_CPP FILENAME DIRECTORY) set(options ENABLE_Wba NO_DEFAULT) set(oneValueArgs HEADER_SUFFIX) set(multiValueArgs ARGUMENTS) - cmake_parse_arguments(_omni "${options}" "${oneValueArgs}" - "${multiValueArgs}" ${ARGN}) + cmake_parse_arguments( + _omni + "${options}" + "${oneValueArgs}" + "${multiValueArgs}" + ${ARGN} + ) if(NOT DEFINED _omni_HEADER_SUFFIX) set(_omni_HEADER_SUFFIX ".hh") endif() @@ -76,8 +81,13 @@ macro(GENERATE_IDL_CPP FILENAME DIRECTORY) endif(${OMNIIDL} STREQUAL OMNIIDL-NOTFOUND) set(IDL_COMPILED_FILES ${FILENAME}SK.cc ${FILENAME}${_omni_HEADER_SUFFIX}) - set(_omniidl_args -bcxx ${_OMNIIDL_INCLUDE_FLAG} -Wbh=${_omni_HEADER_SUFFIX} - ${_omni_ARGUMENTS}) + set( + _omniidl_args + -bcxx + ${_OMNIIDL_INCLUDE_FLAG} + -Wbh=${_omni_HEADER_SUFFIX} + ${_omni_ARGUMENTS} + ) # This is to keep backward compatibility if(NOT _omni_NO_DEFAULT) set(_omniidl_args ${_omniidl_args} -Wbkeep_inc_path) @@ -88,10 +98,11 @@ macro(GENERATE_IDL_CPP FILENAME DIRECTORY) endif(_omni_ENABLE_Wba) add_custom_command( OUTPUT ${IDL_COMPILED_FILES} - COMMAND ${OMNIIDL} ARGS ${_omniidl_args} -C${_PATH} - ${DIRECTORY}/${_NAME}.idl + COMMAND ${OMNIIDL} + ARGS ${_omniidl_args} -C${_PATH} ${DIRECTORY}/${_NAME}.idl MAIN_DEPENDENCY ${DIRECTORY}/${_NAME}.idl - COMMENT "Generating C++ stubs for ${_NAME}") + COMMENT "Generating C++ stubs for ${_NAME}" + ) list(APPEND ALL_IDL_CPP_STUBS ${IDL_COMPILED_FILES}) @@ -99,20 +110,18 @@ macro(GENERATE_IDL_CPP FILENAME DIRECTORY) set_property( DIRECTORY APPEND - PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${IDL_COMPILED_FILES}) + PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${IDL_COMPILED_FILES} + ) set_property( SOURCE ${IDL_COMPILED_FILES} APPEND_STRING PROPERTY COMPILE_FLAGS - "-Wno-conversion -Wno-cast-qual -Wno-unused-variable -Wno-unused-parameter" + "-Wno-conversion -Wno-cast-qual -Wno-unused-variable -Wno-unused-parameter" ) list(APPEND LOGGING_WATCHED_VARIABLES OMNIIDL ALL_IDL_CPP_STUBS) -endmacro( - GENERATE_IDL_CPP - FILENAME - DIRECTORY) +endmacro(GENERATE_IDL_CPP FILENAME DIRECTORY) # .rst: .. command:: GENERATE_IDL_PYTHON (FILENAME DIRECTORY) # @@ -145,8 +154,13 @@ macro(GENERATE_IDL_PYTHON FILENAME DIRECTORY) set(options ENABLE_DOCSTRING) set(oneValueArgs STUBS) set(multiValueArgs ARGUMENTS) - cmake_parse_arguments(_omni "${options}" "${oneValueArgs}" - "${multiValueArgs}" ${ARGN}) + cmake_parse_arguments( + _omni + "${options}" + "${oneValueArgs}" + "${multiValueArgs}" + ${ARGN} + ) get_filename_component(_PATH ${FILENAME} PATH) get_filename_component(_NAME ${FILENAME} NAME) @@ -159,26 +173,38 @@ macro(GENERATE_IDL_PYTHON FILENAME DIRECTORY) endif(${OMNIIDL} STREQUAL OMNIIDL-NOTFOUND) if(_omni_ENABLE_DOCSTRING AND PYTHON_VERSION_MAJOR EQUAL 3) - set(_omniidl_args -p${PROJECT_JRL_CMAKE_MODULE_DIR}/hpp/idl - -bomniidl_be_python_with_docstring -K) + set( + _omniidl_args + -p${PROJECT_JRL_CMAKE_MODULE_DIR}/hpp/idl + -bomniidl_be_python_with_docstring + -K + ) else() set(_omniidl_args -bpython) endif() - set(_omniidl_args ${_omniidl_args} ${_OMNIIDL_INCLUDE_FLAG} -C${_PATH} - ${_omni_ARGUMENTS}) + set( + _omniidl_args + ${_omniidl_args} + ${_OMNIIDL_INCLUDE_FLAG} + -C${_PATH} + ${_omni_ARGUMENTS} + ) if(DEFINED _omni_STUBS) set(_omniidl_args ${_omniidl_args} -Wbstubs=${_omni_STUBS}) string(REPLACE "." "/" _omni_STUBS_DIR ${_omni_STUBS}) endif() - set(output_files - ${CMAKE_CURRENT_BINARY_DIR}/${_PATH}/${_omni_STUBS_DIR}/${FILENAME}_idl.py + set( + output_files + ${CMAKE_CURRENT_BINARY_DIR}/${_PATH}/${_omni_STUBS_DIR}/${FILENAME}_idl.py ) add_custom_command( OUTPUT ${output_files} - COMMAND ${OMNIIDL} ARGS ${_omniidl_args} ${DIRECTORY}/${_NAME}.idl + COMMAND ${OMNIIDL} + ARGS ${_omniidl_args} ${DIRECTORY}/${_NAME}.idl MAIN_DEPENDENCY ${DIRECTORY}/${_NAME}.idl - COMMENT "Generating Python stubs for ${_NAME}") + COMMENT "Generating Python stubs for ${_NAME}" + ) list(APPEND ALL_IDL_PYTHON_STUBS ${output_files}) @@ -186,13 +212,11 @@ macro(GENERATE_IDL_PYTHON FILENAME DIRECTORY) set_property( DIRECTORY APPEND - PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${output_files}) + PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${output_files} + ) list(APPEND LOGGING_WATCHED_VARIABLES OMNIIDL ALL_IDL_PYTHON_STUBS) -endmacro( - GENERATE_IDL_PYTHON - FILENAME - DIRECTORY) +endmacro(GENERATE_IDL_PYTHON FILENAME DIRECTORY) # GENERATE_IDL_FILE FILENAME DIRECTORY # ------------------------------------ @@ -201,9 +225,6 @@ endmacro( macro(GENERATE_IDL_FILE FILENAME DIRECTORY) message( FATAL_ERROR - "GENERATE_IDL_FILE has been removed. Please use GENERATE_IDL_CPP instead." + "GENERATE_IDL_FILE has been removed. Please use GENERATE_IDL_CPP instead." ) -endmacro( - GENERATE_IDL_FILE - FILENAME - DIRECTORY) +endmacro(GENERATE_IDL_FILE FILENAME DIRECTORY) diff --git a/idlrtc.cmake b/idlrtc.cmake index a4383bb2f..10c30cc83 100644 --- a/idlrtc.cmake +++ b/idlrtc.cmake @@ -33,12 +33,12 @@ macro(GENERATE_IDLRTC_FILE FILENAME DIRECTORY) set(OMNIIDL_INC_DIR "") # Check if there is an optional value - message(STATUS "ARGC: "${ARGC}) + message(STATUS "ARGC: " ${ARGC}) if(${ARGC} EQUAL 3) # If there is, the directory to include are added. set(LIST_INCLUDE_DIRECTORIES ${ARGV2}) - message(STATUS "ARGV2: "${ARGV2}) + message(STATUS "ARGV2: " ${ARGV2}) foreach(INCDIR ${LIST_INCLUDE_DIRECTORIES}) # The format for the first one is special to avoid a \ to be introduced. if(OMNIIDL_INC_DIR STREQUAL "") @@ -47,28 +47,41 @@ macro(GENERATE_IDLRTC_FILE FILENAME DIRECTORY) set(OMNIIDL_INC_DIR ${OMNIIDL_INC_DIR} "-I${INCDIR}") endif(OMNIIDL_INC_DIR STREQUAL "") endforeach(INCDIR ${LIST_INCLUDE_DIRECTORIES}) - endif(${ARGC} EQUAL 3) - set(IDL_FLAGS "-Wbuse_quotes" "-Wbh=.hh" "-Wbs=SK.cc" "-Wba" "-Wbd=DynSK.cc") + set( + IDL_FLAGS + "-Wbuse_quotes" + "-Wbh=.hh" + "-Wbs=SK.cc" + "-Wba" + "-Wbd=DynSK.cc" + ) message(STATUS "OMNIIDL_INC_DIR:" ${OMNIIDL_INC_DIR}) add_custom_command( OUTPUT ${FILENAME}SK.cc ${FILENAME}DynSK.cc ${FILENAME}.hh - COMMAND ${OMNIIDL} ARGS -bcxx ${IDL_FLAGS} ${OMNIIDL_INC_DIR} - ${DIRECTORY}/${FILENAME}.idl - MAIN_DEPENDENCY ${DIRECTORY}/${FILENAME}.idl) - set(ALL_IDL_STUBS ${FILENAME}SK.cc ${FILENAME}DynSK.cc ${FILENAME}.hh - ${ALL_IDL_STUBS}) + COMMAND ${OMNIIDL} + ARGS -bcxx ${IDL_FLAGS} ${OMNIIDL_INC_DIR} ${DIRECTORY}/${FILENAME}.idl + MAIN_DEPENDENCY ${DIRECTORY}/${FILENAME}.idl + ) + set( + ALL_IDL_STUBS + ${FILENAME}SK.cc + ${FILENAME}DynSK.cc + ${FILENAME}.hh + ${ALL_IDL_STUBS} + ) # Clean generated files. set_property( DIRECTORY APPEND - PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${FILENAME}SK.cc ${FILENAME}DynSK.cc - ${FILENAME}.hh) + PROPERTY + ADDITIONAL_MAKE_CLEAN_FILES + ${FILENAME}SK.cc + ${FILENAME}DynSK.cc + ${FILENAME}.hh + ) list(APPEND LOGGING_WATCHED_VARIABLES OMNIIDL ALL_IDL_STUBS) -endmacro( - GENERATE_IDLRTC_FILE - FILENAME - DIRECTORY) +endmacro(GENERATE_IDLRTC_FILE FILENAME DIRECTORY) diff --git a/image/visp.cmake b/image/visp.cmake index f159fe2e2..a74eeb3e5 100644 --- a/image/visp.cmake +++ b/image/visp.cmake @@ -35,17 +35,21 @@ macro(FIND_VISP) execute_process( COMMAND ${VISP_CONFIG} --prefix OUTPUT_VARIABLE VISP_PREFIX - OUTPUT_STRIP_TRAILING_WHITESPACE) + OUTPUT_STRIP_TRAILING_WHITESPACE + ) execute_process( COMMAND ${VISP_CONFIG} --cflags OUTPUT_VARIABLE VISP_CFLAGS - OUTPUT_STRIP_TRAILING_WHITESPACE) + OUTPUT_STRIP_TRAILING_WHITESPACE + ) execute_process( COMMAND ${VISP_CONFIG} --libs OUTPUT_VARIABLE VISP_LIBS - OUTPUT_STRIP_TRAILING_WHITESPACE) + OUTPUT_STRIP_TRAILING_WHITESPACE + ) execute_process( COMMAND ${VISP_CONFIG} --dumpversion OUTPUT_VARIABLE VISP_VERSION - OUTPUT_STRIP_TRAILING_WHITESPACE) + OUTPUT_STRIP_TRAILING_WHITESPACE + ) endmacro(FIND_VISP) diff --git a/install-data.cmake b/install-data.cmake index e7c82218a..0481a0126 100644 --- a/install-data.cmake +++ b/install-data.cmake @@ -23,6 +23,7 @@ macro(_INSTALL_PROJECT_DATA) install( FILES ${PROJECT_DATA} DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME} - PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE) + PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE + ) endif(DEFINED PROJECT_DATA) endmacro(_INSTALL_PROJECT_DATA) diff --git a/julia.cmake b/julia.cmake index 6f9f326a3..ec24b5b63 100644 --- a/julia.cmake +++ b/julia.cmake @@ -6,13 +6,20 @@ # :param PKG_NAME: the package to check :param :return Julia_${PKG_NAME}_found # :return: macro(JULIA_CHECK_PACKAGE PKG_NAME) - set(file_content - "try\n@eval import ${PKG_NAME}\nprintln(1)\ncatch\nprintln(0)\nend") - file(WRITE ${PROJECT_SOURCE_DIR}/_tmp_cmake_julia/test_julia_package.jl - ${file_content}) + set( + file_content + "try\n@eval import ${PKG_NAME}\nprintln(1)\ncatch\nprintln(0)\nend" + ) + file( + WRITE + ${PROJECT_SOURCE_DIR}/_tmp_cmake_julia/test_julia_package.jl + ${file_content} + ) execute_process( - COMMAND ${Julia_EXECUTABLE} - ${PROJECT_SOURCE_DIR}/_tmp_cmake_julia/test_julia_package.jl - OUTPUT_VARIABLE Julia_${PKG_NAME}_found) + COMMAND + ${Julia_EXECUTABLE} + ${PROJECT_SOURCE_DIR}/_tmp_cmake_julia/test_julia_package.jl + OUTPUT_VARIABLE Julia_${PKG_NAME}_found + ) file(REMOVE_RECURSE ${PROJECT_SOURCE_DIR}/_tmp_cmake_julia/) endmacro(JULIA_CHECK_PACKAGE PKG_NAME) diff --git a/kineo.cmake b/kineo.cmake index 1ab2df112..25ed2a2cf 100644 --- a/kineo.cmake +++ b/kineo.cmake @@ -34,10 +34,7 @@ # of the .pc file by the macro. # macro(KINEO_ADDON MODULE_NAME) - execute_process( - COMMAND "uname" "-n" - OUTPUT_VARIABLE UNAME_N - ERROR_QUIET) + execute_process(COMMAND "uname" "-n" OUTPUT_VARIABLE UNAME_N ERROR_QUIET) string(REPLACE "\n" "" UNAME_N "${UNAME_N}") set(ADDON_INSTALLDIR lib/modules/${UNAME_N}) @@ -45,16 +42,22 @@ macro(KINEO_ADDON MODULE_NAME) pkg_config_append_libs(${PROJECT_NAME}) add_library(${MODULE_NAME} SHARED ${KINEO_ADDON_SOURCES}) set_target_properties( - ${MODULE_NAME} PROPERTIES SOVERSION ${PROJECT_VERSION} INSTALL_RPATH - ${ADDON_INSTALLDIR}) + ${MODULE_NAME} + PROPERTIES SOVERSION ${PROJECT_VERSION} INSTALL_RPATH ${ADDON_INSTALLDIR} + ) add_custom_command( - OUTPUT ${ADDON_INSTALLDIR}/lib${MODULE_NAME}.kab DEPEND - ${ADDON_INSTALLDIR}/lib${MODULE_NAME}.so - COMMAND KineoAddonBuilder ARGS -m - ${CMAKE_INSTALL_PREFIX}/${ADDON_INSTALLDIR}/lib${MODULE_NAME}.so) + OUTPUT + ${ADDON_INSTALLDIR}/lib${MODULE_NAME}.kab + DEPEND + ${ADDON_INSTALLDIR}/lib${MODULE_NAME}.so + COMMAND KineoAddonBuilder + ARGS -m ${CMAKE_INSTALL_PREFIX}/${ADDON_INSTALLDIR}/lib${MODULE_NAME}.so + ) add_custom_target(license DEPENDS ${ADDON_INSTALLDIR}/lib${MODULE_NAME}.kab) add_dependencies( - license ${CMAKE_INSTALL_PREFIX}/${ADDON_INSTALLDIR}/lib${MODULE_NAME}.so) + license + ${CMAKE_INSTALL_PREFIX}/${ADDON_INSTALLDIR}/lib${MODULE_NAME}.so + ) install(TARGETS ${MODULE_NAME} DESTINATION ${ADDON_INSTALLDIR}) endmacro() @@ -74,12 +77,20 @@ endmacro() # macro(KINEO_STANDALONE STANDALONE_NAME) add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${STANDALONE_NAME}.kab DEPEND - ${CMAKE_CURRENT_BUILD_DIR}/${STANDALONE_NAME} - COMMAND KineoAddonBuilder ARGS -a - ${CMAKE_CURRENT_BINARY_DIR}/${STANDALONE_NAME}) - add_custom_target(${STANDALONE_NAME}-license ALL - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${STANDALONE_NAME}.kab) - add_dependencies(${STANDALONE_NAME}-license - ${CMAKE_CURRENT_BINARY_DIR}/${STANDALONE_NAME}) + OUTPUT + ${CMAKE_CURRENT_BINARY_DIR}/${STANDALONE_NAME}.kab + DEPEND + ${CMAKE_CURRENT_BUILD_DIR}/${STANDALONE_NAME} + COMMAND KineoAddonBuilder + ARGS -a ${CMAKE_CURRENT_BINARY_DIR}/${STANDALONE_NAME} + ) + add_custom_target( + ${STANDALONE_NAME}-license + ALL + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${STANDALONE_NAME}.kab + ) + add_dependencies( + ${STANDALONE_NAME}-license + ${CMAKE_CURRENT_BINARY_DIR}/${STANDALONE_NAME} + ) endmacro() diff --git a/lapack.cmake b/lapack.cmake index 3def1361f..d7f6da10f 100644 --- a/lapack.cmake +++ b/lapack.cmake @@ -55,5 +55,6 @@ macro(SEARCH_FOR_LAPACK) LAPACK95_FOUND BLA_STATIC BLA_VENDOR - BLA_F95) + BLA_F95 + ) endmacro(SEARCH_FOR_LAPACK) diff --git a/logging.cmake b/logging.cmake index b9b8a88a7..7cdea4c81 100644 --- a/logging.cmake +++ b/logging.cmake @@ -26,9 +26,11 @@ set(JRL_CMAKEMODULE_LOGGING_FILENAME "${CMAKE_CURRENT_BINARY_DIR}/config.log") get_directory_property(has_parent_scope PARENT_DIRECTORY) if(has_parent_scope) - set(JRL_CMAKEMODULE_LOGGING_FILENAME - ${JRL_CMAKEMODULE_LOGGING_FILENAME} - PARENT_SCOPE) + set( + JRL_CMAKEMODULE_LOGGING_FILENAME + ${JRL_CMAKEMODULE_LOGGING_FILENAME} + PARENT_SCOPE + ) endif(has_parent_scope) # Watched variables list. All watched variables final value will be displayed in @@ -40,15 +42,17 @@ set(LOGGING_WATCHED_VARIABLES "") set(LOGGING_WATCHED_TARGETS "") # Watched targets properties list. -set(LOGGING_WATCHED_TARGETS_PROPERTIES - COMPILE_DEFINITIONS - COMPILE_FLAGS - DEFINE_SYMBOL - ENABLE_EXPORTS - EXCLUDE_FROM_ALL - LINK_FLAGS - SOVERSION - VERSION) +set( + LOGGING_WATCHED_TARGETS_PROPERTIES + COMPILE_DEFINITIONS + COMPILE_FLAGS + DEFINE_SYMBOL + ENABLE_EXPORTS + EXCLUDE_FROM_ALL + LINK_FLAGS + SOVERSION + VERSION +) # Define character separating values in a portable way. if(UNIX) @@ -72,18 +76,24 @@ function(LOGGING_INITIALIZE) # Write logging file. file(REMOVE ${JRL_CMAKEMODULE_LOGGING_FILENAME}) - file(APPEND ${JRL_CMAKEMODULE_LOGGING_FILENAME} - "This file contains any messages produced by compilers while\n" - "running CMake, to aid debugging if configure makes a mistake.\n\n") + file( + APPEND + ${JRL_CMAKEMODULE_LOGGING_FILENAME} + "This file contains any messages produced by compilers while\n" + "running CMake, to aid debugging if configure makes a mistake.\n\n" + ) file( - APPEND ${JRL_CMAKEMODULE_LOGGING_FILENAME} + APPEND + ${JRL_CMAKEMODULE_LOGGING_FILENAME} "It was created by ${CMAKE_PROJECT_NAME} CMake configuration process " "${PROJECT_VERSION}, which was\n" - "generated by CMake ${CMAKE_VERSION}.\n\n") + "generated by CMake ${CMAKE_VERSION}.\n\n" + ) file( - APPEND ${JRL_CMAKEMODULE_LOGGING_FILENAME} + APPEND + ${JRL_CMAKEMODULE_LOGGING_FILENAME} "## --------- ##\n" "## Platform. ##\n" "## --------- ##\n" @@ -92,7 +102,8 @@ function(LOGGING_INITIALIZE) "system = ${CMAKE_SYSTEM}\n" "processor = ${CMAKE_SYSTEM_PROCESSOR}\n" "generator = ${CMAKE_GENERATOR}\n" - "\n") + "\n" + ) if(NOT "$ENV{PATH}" STREQUAL "") string(REPLACE "${LIST_SEPARATOR}" "\nPATH " PATH "$ENV{PATH}") @@ -102,14 +113,23 @@ function(LOGGING_INITIALIZE) file(APPEND ${JRL_CMAKEMODULE_LOGGING_FILENAME} "PATH " ${PATH} "\n\n") if(NOT "$ENV{PKG_CONFIG_PATH}" STREQUAL "") - string(REPLACE "${LIST_SEPARATOR}" "\nPKG_CONFIG_PATH " PKG_CONFIG_PATH - "$ENV{PKG_CONFIG_PATH}") + string( + REPLACE + "${LIST_SEPARATOR}" + "\nPKG_CONFIG_PATH " + PKG_CONFIG_PATH + "$ENV{PKG_CONFIG_PATH}" + ) else() set(PKG_CONFIG_PATH "undefined") endif() - file(APPEND ${JRL_CMAKEMODULE_LOGGING_FILENAME} "PKG_CONFIG_PATH " - ${PKG_CONFIG_PATH} "\n\n") - + file( + APPEND + ${JRL_CMAKEMODULE_LOGGING_FILENAME} + "PKG_CONFIG_PATH " + ${PKG_CONFIG_PATH} + "\n\n" + ) endfunction(LOGGING_INITIALIZE) # LOGGING_FINALIZE() @@ -119,7 +139,8 @@ endfunction(LOGGING_INITIALIZE) # function(LOGGING_FINALIZE) file( - APPEND ${JRL_CMAKEMODULE_LOGGING_FILENAME} + APPEND + ${JRL_CMAKEMODULE_LOGGING_FILENAME} "## ---------------- ##\n" "## CMake variables. ##\n" "## ---------------- ##\n" @@ -161,11 +182,17 @@ function(LOGGING_FINALIZE) "CMAKE_SHARED_LIBRARY_SUFFIX = ${CMAKE_SHARED_LIBRARY_SUFFIX}\n" "CMAKE_SHARED_MODULE_PREFIX = ${CMAKE_SHARED_MODULE_PREFIX}\n" "CMAKE_SHARED_MODULE_SUFFIX = ${CMAKE_SHARED_MODULE_SUFFIX}\n" - "\n") + "\n" + ) - file(APPEND ${JRL_CMAKEMODULE_LOGGING_FILENAME} - "## ------------------ ##\n" "## Watched variables. ##\n" - "## ------------------ ##\n" "\n") + file( + APPEND + ${JRL_CMAKEMODULE_LOGGING_FILENAME} + "## ------------------ ##\n" + "## Watched variables. ##\n" + "## ------------------ ##\n" + "\n" + ) list(REMOVE_DUPLICATES LOGGING_WATCHED_VARIABLES) foreach(VAR ${LOGGING_WATCHED_VARIABLES}) @@ -175,16 +202,24 @@ function(LOGGING_FINALIZE) file(APPEND ${JRL_CMAKEMODULE_LOGGING_FILENAME} "${VAR} = ${${VAR}}\n") endforeach() - file(APPEND ${JRL_CMAKEMODULE_LOGGING_FILENAME} - "## ---------------- ##\n" "## Watched targets. ##\n" - "## ---------------- ##\n" "\n") + file( + APPEND + ${JRL_CMAKEMODULE_LOGGING_FILENAME} + "## ---------------- ##\n" + "## Watched targets. ##\n" + "## ---------------- ##\n" + "\n" + ) list(REMOVE_DUPLICATES LOGGING_WATCHED_TARGETS) foreach(TARGET ${LOGGING_WATCHED_TARGETS}) foreach(PROPERTY ${LOGGING_WATCHED_TARGETS_PROPERTIES}) get_target_property(VALUE ${TARGET} ${PROPERTY}) - file(APPEND ${JRL_CMAKEMODULE_LOGGING_FILENAME} - "${TARGET}_${PROPERTY} = ${VALUE}\n") + file( + APPEND + ${JRL_CMAKEMODULE_LOGGING_FILENAME} + "${TARGET}_${PROPERTY} = ${VALUE}\n" + ) endforeach() file(APPEND ${JRL_CMAKEMODULE_LOGGING_FILENAME} "\n") endforeach() diff --git a/man.cmake b/man.cmake index c57458326..389081d5d 100644 --- a/man.cmake +++ b/man.cmake @@ -30,14 +30,17 @@ macro(MANPAGE NAME) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.1 - COMMAND ${POD2MAN} --section=1 --center="LOCAL USER COMMANDS" --release - ${PROJECT_NAME} ${NAME}.pod > ${NAME}.1 - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.pod) + COMMAND + ${POD2MAN} --section=1 --center="LOCAL USER COMMANDS" --release + ${PROJECT_NAME} ${NAME}.pod > ${NAME}.1 + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.pod + ) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.1.gz COMMAND ${GZIP} -c ${NAME}.1 > ${NAME}.1.gz - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.1) + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.1 + ) # Trigger man page generation at install. install(CODE "EXECUTE_PROCESS(COMMAND ${CMAKE_MAKE_PROGRAM} man)") @@ -49,8 +52,10 @@ macro(MANPAGE NAME) endif(MANDIR) # Install man page. - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.1.gz - DESTINATION ${DESTINATION_MAN_PAGE}) + install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.1.gz + DESTINATION ${DESTINATION_MAN_PAGE} + ) list(APPEND LOGGING_WATCHED_VARIABLES POD2MAN GZIP) endmacro(MANPAGE) diff --git a/metapodfromurdf.cmake b/metapodfromurdf.cmake index 015eb108e..ced93f807 100644 --- a/metapodfromurdf.cmake +++ b/metapodfromurdf.cmake @@ -15,12 +15,14 @@ # this program. If not, see . macro(ADD_METAPOD_FROM_URDF_MODEL model_name) - set(robot_name "robot_${model_name}") set(lib_robot_name "metapod_${model_name}") set(dir_robot ${PROJECT_BINARY_DIR}/include/metapod/models/${model_name}) - set(robot_name_sources ${dir_robot}/${model_name}.hh - ${dir_robot}/${model_name}.cc) + set( + robot_name_sources + ${dir_robot}/${model_name}.hh + ${dir_robot}/${model_name}.cc + ) set(data_robot_dir ${METAPOD_PREFIX}/share/metapod/data/${model_name}) set(config_file_robot ${data_robot_dir}/${model_name}.config) set(license_file_robot ${data_robot_dir}/${model_name}_license_file.txt) @@ -30,6 +32,7 @@ macro(ADD_METAPOD_FROM_URDF_MODEL model_name) OUTPUT ${robot_name_sources} COMMAND metapodfromurdf --name ${model_name} --libname ${lib_robot_name} - --directory ${dir_robot} --config-file ${config_file_robot} - --license-file ${license_file_robot} ${urdf_file_robot}) + --directory ${dir_robot} --config-file ${config_file_robot} --license-file + ${license_file_robot} ${urdf_file_robot} + ) endmacro(ADD_METAPOD_FROM_URDF_MODEL) diff --git a/modernize-links.cmake b/modernize-links.cmake index be3b78bb1..3af002ef2 100644 --- a/modernize-links.cmake +++ b/modernize-links.cmake @@ -18,8 +18,13 @@ macro(MODERNIZE_TARGET_LINK_LIBRARIES target) set(options) set(oneValueArgs SCOPE) set(multiValueArgs TARGETS LIBRARIES INCLUDE_DIRS) - cmake_parse_arguments(MODERNIZE_LINK "${options}" "${oneValueArgs}" - "${multiValueArgs}" ${ARGN}) + cmake_parse_arguments( + MODERNIZE_LINK + "${options}" + "${oneValueArgs}" + "${multiValueArgs}" + ${ARGN} + ) set(_targets_available TRUE) foreach(_tgt ${MODERNIZE_LINK_TARGETS}) @@ -33,12 +38,22 @@ macro(MODERNIZE_TARGET_LINK_LIBRARIES target) endforeach() if(_targets_available) - target_link_libraries(${target} ${MODERNIZE_LINK_SCOPE} - ${MODERNIZE_LINK_TARGETS}) + target_link_libraries( + ${target} + ${MODERNIZE_LINK_SCOPE} + ${MODERNIZE_LINK_TARGETS} + ) else() - target_link_libraries(${target} ${MODERNIZE_LINK_SCOPE} - ${MODERNIZE_LINK_LIBRARIES}) - target_include_directories(${target} SYSTEM ${MODERNIZE_LINK_SCOPE} - ${MODERNIZE_LINK_INCLUDE_DIRS}) + target_link_libraries( + ${target} + ${MODERNIZE_LINK_SCOPE} + ${MODERNIZE_LINK_LIBRARIES} + ) + target_include_directories( + ${target} + SYSTEM + ${MODERNIZE_LINK_SCOPE} + ${MODERNIZE_LINK_INCLUDE_DIRS} + ) endif() endmacro() diff --git a/msvc-specific.cmake b/msvc-specific.cmake index 286f84445..973a1453b 100644 --- a/msvc-specific.cmake +++ b/msvc-specific.cmake @@ -30,7 +30,9 @@ # macro(GET_MSVC_VERSION) message( - DEPRECATION "This macro is deprecated. Use GET_MSVC_TOOLS_VERSION instead.") + DEPRECATION + "This macro is deprecated. Use GET_MSVC_TOOLS_VERSION instead." + ) if(MSVC60) set(MSVC_VERSION "6.0") elseif(MSVC70) @@ -54,13 +56,14 @@ macro(GET_MSVC_VERSION) set(MSVC_VERSION "14.0") message( AUTHOR_WARNING - "MSVC version not found. Set MSVC_VERSION to 14.0 by default. Please update the GET_MSVC_VERSION macro." + "MSVC version not found. Set MSVC_VERSION to 14.0 by default. Please update the GET_MSVC_VERSION macro." ) else() set(MSVC_VERSION "") message( AUTHOR_WARNING - "MSVC version not found. You are not using a MSVC generator.") + "MSVC version not found. You are not using a MSVC generator." + ) endif() endif() endmacro(GET_MSVC_VERSION) @@ -77,7 +80,7 @@ macro(GET_MSVC_TOOLS_VERSION) if(CONTAINS_DOT) message( AUTHOR_WARNING - "MSVC_VERSION has been overwritten with a tools version number (likely by a call to deprecated GET_MSVC_VERSION. Using this number." + "MSVC_VERSION has been overwritten with a tools version number (likely by a call to deprecated GET_MSVC_VERSION. Using this number." ) set(MSVC_TOOLS_VERSION ${MSVC_VERSION}) else() @@ -108,13 +111,14 @@ macro(GET_MSVC_TOOLS_VERSION) set(MSVC_TOOLS_VERSION "16.0") message( AUTHOR_WARNING - "MSVC version not found. Assuming newer version and set MSVC_TOOLS_VERSION to 16.0 by default. Please update the GET_MSVC_TOOLS_VERSION macro." + "MSVC version not found. Assuming newer version and set MSVC_TOOLS_VERSION to 16.0 by default. Please update the GET_MSVC_TOOLS_VERSION macro." ) else() set(MSVC_TOOLS_VERSION "") message( AUTHOR_WARNING - "MSVC version not found. You are not using a MSVC generator.") + "MSVC version not found. You are not using a MSVC generator." + ) endif() endif() endif() @@ -135,13 +139,19 @@ macro(REQUIRE_MINIMUM_MSVC_VERSION VERSION) get_msvc_tools_version() if(${MSVC_TOOLS_VERSION}) if(NOT ${MSVC_TOOLS_VERSION} VERSION_GREATER ${VERSION}) - message(FATAL_ERROR "Minimum MSVC version required is " ${VERSION} - " but version " ${MSVC_TOOLS_VERSION} " was found.") + message( + FATAL_ERROR + "Minimum MSVC version required is " + ${VERSION} + " but version " + ${MSVC_TOOLS_VERSION} + " was found." + ) endif() else() message( FATAL_ERROR - "You are requiring a minimum version for MSVC but you do not use a MSVC generator." + "You are requiring a minimum version for MSVC but you do not use a MSVC generator." ) endif(${MSVC_TOOLS_VERSION}) endmacro(REQUIRE_MINIMUM_MSVC_VERSION) @@ -166,15 +176,23 @@ macro(GENERATE_MSVC_DOT_USER_FILE) if(MSVC) require_minimum_msvc_version("10.0") - set(oneValueArgs NAME COMMAND COMMAND_ARGS WORKING_DIRECTORY - ADDITIONAL_PATH) + set( + oneValueArgs + NAME + COMMAND + COMMAND_ARGS + WORKING_DIRECTORY + ADDITIONAL_PATH + ) cmake_parse_arguments(GMDUT "" "${oneValueArgs}" "" ${ARGN}) - if((NOT GMDUT_NAME) - AND (NOT GMDUT_COMMAND) - AND (NOT GMDUT_COMMAND_ARGS) - AND (NOT GMDUT_WORK_DIR) - AND (NOT GMDUT_ADDITIONAL_PATH)) + if( + (NOT GMDUT_NAME) + AND (NOT GMDUT_COMMAND) + AND (NOT GMDUT_COMMAND_ARGS) + AND (NOT GMDUT_WORK_DIR) + AND (NOT GMDUT_ADDITIONAL_PATH) + ) # legacy version set(GMDUT_NAME ${ARGV0}) if(${ARGC} GREATER 1) @@ -183,7 +201,7 @@ macro(GENERATE_MSVC_DOT_USER_FILE) endif() if("${CMAKE_MSVCIDE_RUN_PATH}" STREQUAL "") - set(CMAKE_MSVCIDE_RUN_PATH "$(SolutionDir)\src\$(Configuration)") + set(CMAKE_MSVCIDE_RUN_PATH "${SolutionDir}\\src\\${Configuration}") endif() if(NOT GMDUT_NAME) @@ -200,10 +218,14 @@ macro(GENERATE_MSVC_DOT_USER_FILE) endif() get_msvc_tools_version() - set(DOT_USER_TEMPLATE_PATH - ${PROJECT_JRL_CMAKE_MODULE_DIR}/msvc.vcxproj.user.in) - set(DOT_USER_FILE_PATH - ${CMAKE_CURRENT_BINARY_DIR}/${GMDUT_NAME}.vcxproj.user) + set( + DOT_USER_TEMPLATE_PATH + ${PROJECT_JRL_CMAKE_MODULE_DIR}/msvc.vcxproj.user.in + ) + set( + DOT_USER_FILE_PATH + ${CMAKE_CURRENT_BINARY_DIR}/${GMDUT_NAME}.vcxproj.user + ) configure_file(${DOT_USER_TEMPLATE_PATH} ${DOT_USER_FILE_PATH}) unset(MSVC_DOT_USER_ADDITIONAL_PATH_DOT_USER) diff --git a/openhrp.cmake b/openhrp.cmake index e575c520f..7410fd9e5 100644 --- a/openhrp.cmake +++ b/openhrp.cmake @@ -23,7 +23,8 @@ macro(SEARCH_GRX) include/rtm/idl/SDOPackage.hh HINTS /opt/grx/ DOC "GRX software prefix (i.e. '/opt/grxX.Y')" - NO_DEFAULT_PATH) + NO_DEFAULT_PATH + ) endmacro(SEARCH_GRX) # Search if openhrp3.0(.7) is installed. Set the value GRX_PREFIX if found @@ -35,7 +36,8 @@ macro(SEARCH_GRX3) OpenHRP/DynamicsSimulator/server/DynamicsSimulator HINTS /opt/grx3.0 DOC "GRX software prefix (i.e. '/opt/grxX.Y')" - NO_DEFAULT_PATH) + NO_DEFAULT_PATH + ) endmacro(SEARCH_GRX3) # Check the robots installed in openhrp Args: the robot researched (and handled @@ -56,7 +58,7 @@ macro(SEARCH_GRX_ROBOTS HANDLED_ROBOTS) if(NOT GRX_ROBOTS) message( FATAL_ERROR - "None of the following robots (${HANDLED_ROBOTS}) were found in ${GRX_PREFIX}." + "None of the following robots (${HANDLED_ROBOTS}) were found in ${GRX_PREFIX}." ) else() message("The following robots were found: ${GRX_ROBOTS}") diff --git a/openhrpcontroller.cmake b/openhrpcontroller.cmake index 28ba292d6..1e5135a19 100644 --- a/openhrpcontroller.cmake +++ b/openhrpcontroller.cmake @@ -22,8 +22,11 @@ macro(create_simple_controller CONTROLLER_NAME) target_link_libraries(${CONTROLLER_NAME} ${OPENRTM_LIBRARIES}) set_target_properties(${CONTROLLER_NAME} PROPERTIES PREFIX "") - add_executable(${CONTROLLER_NAME}Comp ${CONTROLLER_NAME}Comp.cpp - ${CONTROLLER_NAME}.cpp) + add_executable( + ${CONTROLLER_NAME}Comp + ${CONTROLLER_NAME}Comp.cpp + ${CONTROLLER_NAME}.cpp + ) target_link_libraries(${CONTROLLER_NAME}Comp ${OPENRTM_LIBRARIES}) if(WIN32) @@ -34,15 +37,25 @@ macro(create_simple_controller CONTROLLER_NAME) set(controller_install_path lib/openhrp/controller/${CONTROLLER_NAME}) install( - TARGETS ${CONTROLLER_NAME} ${CONTROLLER_NAME}Comp - DESTINATION ${controller_install_path} - CONFIGURATIONS Release) + TARGETS + ${CONTROLLER_NAME} + ${CONTROLLER_NAME}Comp + DESTINATION + ${controller_install_path} + CONFIGURATIONS + Release + ) if(WIN32) install( - TARGETS ${CONTROLLER_NAME} ${CONTROLLER_NAME}Comp - DESTINATION ${PROJECT_SOURCE_DIR} - CONFIGURATIONS Release) + TARGETS + ${CONTROLLER_NAME} + ${CONTROLLER_NAME}Comp + DESTINATION + ${PROJECT_SOURCE_DIR} + CONFIGURATIONS + Release + ) endif() install(FILES rtc.conf bridge.conf DESTINATION ${controller_install_path}) @@ -51,7 +64,7 @@ macro(create_simple_controller CONTROLLER_NAME) install( DIRECTORY etc DESTINATION ${controller_install_path} - PATTERN ".svn" EXCLUDE) + PATTERN ".svn" EXCLUDE + ) endif() - endmacro() diff --git a/openrtm.cmake b/openrtm.cmake index e93f601b5..20e56d960 100644 --- a/openrtm.cmake +++ b/openrtm.cmake @@ -15,9 +15,11 @@ # OpenRTM-aist macro(openrtm) - - set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} - ${PROJECT_JRL_CMAKE_MODULE_DIR}/find-external/OpenRTM) + set( + CMAKE_MODULE_PATH + ${CMAKE_MODULE_PATH} + ${PROJECT_JRL_CMAKE_MODULE_DIR}/find-external/OpenRTM + ) find_package(OpenRTM REQUIRED) set(ADDITIONAL_SYMBOL "") @@ -27,8 +29,10 @@ macro(openrtm) add_definitions(${OPENRTM_DEFINITIONS}) endif() - set(OPENHRP_RTM_IDL_DIR - "${OpenHRP_SOURCE_DIR}/idl/OpenRTM/${OPENRTM_VERSION}") + set( + OPENHRP_RTM_IDL_DIR + "${OpenHRP_SOURCE_DIR}/idl/OpenRTM/${OPENRTM_VERSION}" + ) if(OPENRTM_VERSION STREQUAL OPENRTM_VERSION042) set(ADDITIONAL_SYMBOL "OPENRTM_VERSION_042") endif() @@ -44,5 +48,4 @@ macro(openrtm) endif() add_definitions(${OMNIORB_CFLAGS}) - endmacro(openrtm) diff --git a/package-config.cmake b/package-config.cmake index 7f664c4c1..a905c0126 100644 --- a/package-config.cmake +++ b/package-config.cmake @@ -40,21 +40,11 @@ macro(_SETUP_PROJECT_PACKAGE_INIT) set(TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets") set(namespace "${PROJECT_NAME}::") - set(_PACKAGE_CONFIG_DEPENDENCIES_PROJECTS - "" - CACHE INTERNAL "") - set(_PACKAGE_CONFIG_DEPENDENCIES_FIND_PACKAGE - "" - CACHE INTERNAL "") - set(_PACKAGE_CONFIG_DEPENDENCIES_FIND_DEPENDENCY - "" - CACHE INTERNAL "") - set(_PACKAGE_CONFIG_DEPENDENCIES_FIND_EXTERNAL - "" - CACHE INTERNAL "") - set(PACKAGE_EXTRA_MACROS - "" - CACHE INTERNAL "") + set(_PACKAGE_CONFIG_DEPENDENCIES_PROJECTS "" CACHE INTERNAL "") + set(_PACKAGE_CONFIG_DEPENDENCIES_FIND_PACKAGE "" CACHE INTERNAL "") + set(_PACKAGE_CONFIG_DEPENDENCIES_FIND_DEPENDENCY "" CACHE INTERNAL "") + set(_PACKAGE_CONFIG_DEPENDENCIES_FIND_EXTERNAL "" CACHE INTERNAL "") + set(PACKAGE_EXTRA_MACROS "" CACHE INTERNAL "") endmacro(_SETUP_PROJECT_PACKAGE_INIT) # .rst: @@ -85,54 +75,80 @@ macro(ADD_PROJECT_DEPENDENCY) # add dependency to the generated .pc ref # https://github.com/jrl-umi3218/jrl-cmakemodules/pull/335 cmake_parse_arguments( - PARSED_ARGN "" "PKG_CONFIG_REQUIRES;FOR_COMPONENT;FIND_EXTERNAL" "" ${ARGN}) + PARSED_ARGN + "" + "PKG_CONFIG_REQUIRES;FOR_COMPONENT;FIND_EXTERNAL" + "" + ${ARGN} + ) if(PARSED_ARGN_PKG_CONFIG_REQUIRES) _add_to_list_if_not_present(_PKG_CONFIG_REQUIRES - "${PARSED_ARGN_PKG_CONFIG_REQUIRES}") + "${PARSED_ARGN_PKG_CONFIG_REQUIRES}" + ) _add_to_list_if_not_present(_PKG_CONFIG_DEP_NOT_FOR_CONFIG_CMAKE - "${PARSED_ARGN_PKG_CONFIG_REQUIRES}") + "${PARSED_ARGN_PKG_CONFIG_REQUIRES}" + ) endif() if(PARSED_ARGN_FOR_COMPONENT) set(component "_${PARSED_ARGN_FOR_COMPONENT}") endif(PARSED_ARGN_FOR_COMPONENT) if(PARSED_ARGN_FIND_EXTERNAL) set(_ext "find-external/${PARSED_ARGN_FIND_EXTERNAL}") - set(CMAKE_MODULE_PATH "${PROJECT_JRL_CMAKE_MODULE_DIR}/${_ext}" - ${CMAKE_MODULE_PATH}) + set( + CMAKE_MODULE_PATH + "${PROJECT_JRL_CMAKE_MODULE_DIR}/${_ext}" + ${CMAKE_MODULE_PATH} + ) set(_ext_path "${CONFIG_INSTALL_DIR}/${_ext}") if(NOT IS_ABSOLUTE ${_ext_path}) set(_ext_path "\${PACKAGE_PREFIX_DIR}/${_ext_path}") endif() - set(_PACKAGE_CONFIG_DEPENDENCIES_FIND_EXTERNAL - "${_PACKAGE_CONFIG_DEPENDENCIES_FIND_EXTERNAL}\n ${_ext_path}") - install(DIRECTORY "${PROJECT_JRL_CMAKE_MODULE_DIR}/${_ext}" - DESTINATION "${CONFIG_INSTALL_DIR}/find-external") + set( + _PACKAGE_CONFIG_DEPENDENCIES_FIND_EXTERNAL + "${_PACKAGE_CONFIG_DEPENDENCIES_FIND_EXTERNAL}\n ${_ext_path}" + ) + install( + DIRECTORY "${PROJECT_JRL_CMAKE_MODULE_DIR}/${_ext}" + DESTINATION "${CONFIG_INSTALL_DIR}/find-external" + ) endif() _add_to_list_if_not_present(_PACKAGE_CONFIG${component}_DEPENDENCIES_PROJECTS - "${ARGV0}") + "${ARGV0}" + ) string(REPLACE ";" " " PACKAGE_ARGS "${PARSED_ARGN_UNPARSED_ARGUMENTS}") _add_to_list_if_not_present( _PACKAGE_CONFIG${component}_DEPENDENCIES_FIND_PACKAGE - "find_package(${PACKAGE_ARGS})") + "find_package(${PACKAGE_ARGS})" + ) _add_to_list_if_not_present( _PACKAGE_CONFIG${component}_DEPENDENCIES_FIND_DEPENDENCY - "find_dependency(${PACKAGE_ARGS})") + "find_dependency(${PACKAGE_ARGS})" + ) list(GET PARSED_ARGN_UNPARSED_ARGUMENTS 0 _package_name) if(NOT ${_package_name} IN_LIST PROJECT_PACKAGES_IN_WORKSPACE) find_package(${PARSED_ARGN_UNPARSED_ARGUMENTS}) endif() # Propagate variables changes to the cached values - set(_PACKAGE_CONFIG${component}_DEPENDENCIES_PROJECTS - "${_PACKAGE_CONFIG${component}_DEPENDENCIES_PROJECTS}" - CACHE INTERNAL "") - set(_PACKAGE_CONFIG${component}_DEPENDENCIES_FIND_PACKAGE - "${_PACKAGE_CONFIG${component}_DEPENDENCIES_FIND_PACKAGE}" - CACHE INTERNAL "") - set(_PACKAGE_CONFIG${component}_DEPENDENCIES_FIND_DEPENDENCY - "${_PACKAGE_CONFIG${component}_DEPENDENCIES_FIND_DEPENDENCY}" - CACHE INTERNAL "") + set( + _PACKAGE_CONFIG${component}_DEPENDENCIES_PROJECTS + "${_PACKAGE_CONFIG${component}_DEPENDENCIES_PROJECTS}" + CACHE INTERNAL + "" + ) + set( + _PACKAGE_CONFIG${component}_DEPENDENCIES_FIND_PACKAGE + "${_PACKAGE_CONFIG${component}_DEPENDENCIES_FIND_PACKAGE}" + CACHE INTERNAL + "" + ) + set( + _PACKAGE_CONFIG${component}_DEPENDENCIES_FIND_DEPENDENCY + "${_PACKAGE_CONFIG${component}_DEPENDENCIES_FIND_DEPENDENCY}" + CACHE INTERNAL + "" + ) endmacro() # .rst: @@ -186,28 +202,45 @@ macro(SETUP_PROJECT_PACKAGE_FINALIZE) set(TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets") set(namespace "${PROJECT_NAME}::") string(TOUPPER "${PROJECT_NAME}" PROJECT_NAME_UPPER) - string(REGEX REPLACE "[^a-zA-Z0-9]" "_" PROJECT_NAME_UPPER - "${PROJECT_NAME_UPPER}") + string( + REGEX REPLACE + "[^a-zA-Z0-9]" + "_" + PROJECT_NAME_UPPER + "${PROJECT_NAME_UPPER}" + ) # Include module with fuction 'write_basic_package_version_file' include(CMakePackageConfigHelpers) - string(REPLACE ";" "\n " PACKAGE_DEPENDENCIES_FIND_PACKAGE - "${_PACKAGE_CONFIG_DEPENDENCIES_FIND_PACKAGE}") - string(REPLACE ";" "\n " PACKAGE_DEPENDENCIES_FIND_DEPENDENCY - "${_PACKAGE_CONFIG_DEPENDENCIES_FIND_DEPENDENCY}") + string( + REPLACE + ";" + "\n " + PACKAGE_DEPENDENCIES_FIND_PACKAGE + "${_PACKAGE_CONFIG_DEPENDENCIES_FIND_PACKAGE}" + ) + string( + REPLACE + ";" + "\n " + PACKAGE_DEPENDENCIES_FIND_DEPENDENCY + "${_PACKAGE_CONFIG_DEPENDENCIES_FIND_DEPENDENCY}" + ) if(DEFINED _MINIMAL_CXX_STANDARD) install_jrl_cmakemodules_file("cxx-standard.cmake") # Add check for standard - enforce if required if(${MINIMAL_CXX_STANDARD_ENFORCE}) - set(PACKAGE_EXTRA_MACROS - "${PACKAGE_EXTRA_MACROS}\nCHECK_MINIMAL_CXX_STANDARD(${_MINIMAL_CXX_STANDARD} ENFORCE)" + set( + PACKAGE_EXTRA_MACROS + "${PACKAGE_EXTRA_MACROS}\nCHECK_MINIMAL_CXX_STANDARD(${_MINIMAL_CXX_STANDARD} ENFORCE)" ) else() - set(PACKAGE_EXTRA_MACROS - "${PACKAGE_EXTRA_MACROS}\nCHECK_MINIMAL_CXX_STANDARD(${_MINIMAL_CXX_STANDARD})" + set( + PACKAGE_EXTRA_MACROS + "${PACKAGE_EXTRA_MACROS}\nCHECK_MINIMAL_CXX_STANDARD(${_MINIMAL_CXX_STANDARD})" ) endif() endif() @@ -220,7 +253,8 @@ macro(SETUP_PROJECT_PACKAGE_FINALIZE) write_basic_package_version_file( "${VERSION_CONFIG}" VERSION ${PROJECT_VERSION} - COMPATIBILITY ${PROJECT_COMPATIBILITY_VERSION}) + COMPATIBILITY ${PROJECT_COMPATIBILITY_VERSION} + ) # Configure 'Config.cmake' Use variables: * TARGETS_EXPORT_NAME # * PROJECT_NAME * _PKG_CONFIG_REQUIRES @@ -234,32 +268,38 @@ macro(SETUP_PROJECT_PACKAGE_FINALIZE) endif(_PKG_CONFIG_REQUIRES) if(NOT PROJECT_EXPORT_NO_TARGET) - set(INCLUDE_TARGETS_FILE - "include(\"\${CMAKE_CURRENT_LIST_DIR}/${TARGETS_EXPORT_NAME}.cmake\")") + set( + INCLUDE_TARGETS_FILE + "include(\"\${CMAKE_CURRENT_LIST_DIR}/${TARGETS_EXPORT_NAME}.cmake\")" + ) else() set(INCLUDE_TARGETS_FILE "# Package with no targets") endif() set(INSTALL_FULL_INCLUDEDIR ${CMAKE_INSTALL_FULL_INCLUDEDIR}) configure_package_config_file( - "${PROJECT_JRL_CMAKE_MODULE_DIR}/Config.cmake.in" "${PROJECT_CONFIG}" + "${PROJECT_JRL_CMAKE_MODULE_DIR}/Config.cmake.in" + "${PROJECT_CONFIG}" INSTALL_DESTINATION "${CONFIG_INSTALL_DIR}" - PATH_VARS INSTALL_FULL_INCLUDEDIR) + PATH_VARS INSTALL_FULL_INCLUDEDIR + ) unset(INSTALL_FULL_INCLUDEDIR) # Config * /lib/cmake/Foo/FooConfig.cmake * # /lib/cmake/Foo/FooConfigVersion.cmake - install(FILES "${PROJECT_CONFIG}" "${VERSION_CONFIG}" - DESTINATION "${CONFIG_INSTALL_DIR}") + install( + FILES "${PROJECT_CONFIG}" "${VERSION_CONFIG}" + DESTINATION "${CONFIG_INSTALL_DIR}" + ) # Config * /lib/cmake/Foo/FooTargets.cmake if(NOT PROJECT_EXPORT_NO_TARGET) install( EXPORT "${TARGETS_EXPORT_NAME}" NAMESPACE "${namespace}" - DESTINATION "${CONFIG_INSTALL_DIR}") + DESTINATION "${CONFIG_INSTALL_DIR}" + ) endif() - endmacro(SETUP_PROJECT_PACKAGE_FINALIZE) # .rst: .. command:: PROJECT_INSTALL_COMPONENT(COMPONENT [EXTRA_MACRO @@ -284,24 +324,41 @@ macro(PROJECT_INSTALL_COMPONENT COMPONENT) install( EXPORT ${COMPONENT}Targets NAMESPACE "${namespace}" - DESTINATION "${CONFIG_INSTALL_DIR}") + DESTINATION "${CONFIG_INSTALL_DIR}" + ) set(COMPONENT ${COMPONENT}) - set(_PACKAGE_CONFIG_COMPONENT_DEPENDENCIES_PROJECTS - "${_PACKAGE_CONFIG_${COMPONENT}_DEPENDENCIES_PROJECTS}") - string(REPLACE ";" "\n " COMPONENT_FIND_PACKAGE - "${_PACKAGE_CONFIG_${COMPONENT}_DEPENDENCIES_FIND_PACKAGE}") - string(REPLACE ";" "\n " COMPONENT_FIND_DEPENDENCY - "${_PACKAGE_CONFIG_${COMPONENT}_DEPENDENCIES_FIND_DEPENDENCY}") - set(COMPONENT_CONFIG - "${PROJECT_BINARY_DIR}/generated/${COMPONENT}Config.cmake") + set( + _PACKAGE_CONFIG_COMPONENT_DEPENDENCIES_PROJECTS + "${_PACKAGE_CONFIG_${COMPONENT}_DEPENDENCIES_PROJECTS}" + ) + string( + REPLACE + ";" + "\n " + COMPONENT_FIND_PACKAGE + "${_PACKAGE_CONFIG_${COMPONENT}_DEPENDENCIES_FIND_PACKAGE}" + ) + string( + REPLACE + ";" + "\n " + COMPONENT_FIND_DEPENDENCY + "${_PACKAGE_CONFIG_${COMPONENT}_DEPENDENCIES_FIND_DEPENDENCY}" + ) + set( + COMPONENT_CONFIG + "${PROJECT_BINARY_DIR}/generated/${COMPONENT}Config.cmake" + ) set(COMPONENT_EXTRA_MACRO "${PARSED_ARGN_EXTRA_MACRO}") include(CMakePackageConfigHelpers) configure_package_config_file( "${PROJECT_JRL_CMAKE_MODULE_DIR}/componentConfig.cmake.in" "${COMPONENT_CONFIG}" INSTALL_DESTINATION "${CONFIG_INSTALL_DIR}" - NO_CHECK_REQUIRED_COMPONENTS_MACRO NO_SET_AND_CHECK_MACRO) + NO_CHECK_REQUIRED_COMPONENTS_MACRO + NO_SET_AND_CHECK_MACRO + ) install(FILES "${COMPONENT_CONFIG}" DESTINATION "${CONFIG_INSTALL_DIR}") endmacro() @@ -310,10 +367,13 @@ endmacro() # install jrl-cmakemodules/$filename along CMake package exports # macro(INSTALL_JRL_CMAKEMODULES_FILE filename) - install(FILES "${PROJECT_JRL_CMAKE_MODULE_DIR}/${filename}" - DESTINATION "${CONFIG_INSTALL_DIR}") - set(INCLUDE_INSTALLED_JRL_FILES - "${INCLUDE_INSTALLED_JRL_FILES}\ninclude(\"\${CMAKE_CURRENT_LIST_DIR}/${filename}\")" + install( + FILES "${PROJECT_JRL_CMAKE_MODULE_DIR}/${filename}" + DESTINATION "${CONFIG_INSTALL_DIR}" + ) + set( + INCLUDE_INSTALLED_JRL_FILES + "${INCLUDE_INSTALLED_JRL_FILES}\ninclude(\"\${CMAKE_CURRENT_LIST_DIR}/${filename}\")" ) endmacro() @@ -322,6 +382,8 @@ endmacro() # install jrl-cmakemodules/$dirname along CMake package exports # macro(INSTALL_JRL_CMAKEMODULES_DIR dirname) - install(DIRECTORY "${PROJECT_JRL_CMAKE_MODULE_DIR}/${dirname}" - DESTINATION "${CONFIG_INSTALL_DIR}") + install( + DIRECTORY "${PROJECT_JRL_CMAKE_MODULE_DIR}/${dirname}" + DESTINATION "${CONFIG_INSTALL_DIR}" + ) endmacro() diff --git a/pkg-config.cmake b/pkg-config.cmake index b03978993..b7d211254 100644 --- a/pkg-config.cmake +++ b/pkg-config.cmake @@ -32,15 +32,20 @@ function(_list_join var_in sep var_out) endif() endforeach() endif() - set(${var_out} - ${out} - PARENT_SCOPE) + set(${var_out} ${out} PARENT_SCOPE) endfunction() # Additional pkg-config variables whose value will be imported during the # dependency check. -set(PKG_CONFIG_ADDITIONAL_VARIABLES bindir pkglibdir datarootdir pkgdatarootdir - docdir doxygendocdir) +set( + PKG_CONFIG_ADDITIONAL_VARIABLES + bindir + pkglibdir + datarootdir + pkgdatarootdir + docdir + doxygendocdir +) # .rst: .. ifmode:: internal # @@ -54,119 +59,113 @@ set(PKG_CONFIG_ADDITIONAL_VARIABLES bindir pkglibdir datarootdir pkgdatarootdir macro(_SETUP_PROJECT_PKG_CONFIG) # Pkg-config related commands. rel_install_path("${CMAKE_INSTALL_LIBDIR}/pkgconfig" _PC_REL_INSTALL_PATH) - set(_PKG_CONFIG_PREFIX - "\${pcfiledir}/${_PC_REL_INSTALL_PATH}" - CACHE INTERNAL "") - set(_PKG_CONFIG_EXEC_PREFIX - "${_PKG_CONFIG_PREFIX}" - CACHE INTERNAL "") - set(_PKG_CONFIG_LIBDIR - "${_PKG_CONFIG_PREFIX}/${CMAKE_INSTALL_LIBDIR}" - CACHE INTERNAL "") - set(_PKG_CONFIG_BINDIR - "${_PKG_CONFIG_PREFIX}/${CMAKE_INSTALL_BINDIR}" - CACHE INTERNAL "") - set(_PKG_CONFIG_PKGLIBDIR - "${_PKG_CONFIG_PREFIX}/${CMAKE_INSTALL_PKGLIBDIR}" - CACHE INTERNAL "") - set(_PKG_CONFIG_INCLUDEDIR - "${_PKG_CONFIG_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}" - CACHE INTERNAL "") - set(_PKG_CONFIG_DATAROOTDIR - "${_PKG_CONFIG_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}" - CACHE INTERNAL "") - set(_PKG_CONFIG_PKGDATAROOTDIR - "${_PKG_CONFIG_PREFIX}/${CMAKE_INSTALL_DATADIR}" - CACHE INTERNAL "") + set( + _PKG_CONFIG_PREFIX + "\${pcfiledir}/${_PC_REL_INSTALL_PATH}" + CACHE INTERNAL + "" + ) + set(_PKG_CONFIG_EXEC_PREFIX "${_PKG_CONFIG_PREFIX}" CACHE INTERNAL "") + set( + _PKG_CONFIG_LIBDIR + "${_PKG_CONFIG_PREFIX}/${CMAKE_INSTALL_LIBDIR}" + CACHE INTERNAL + "" + ) + set( + _PKG_CONFIG_BINDIR + "${_PKG_CONFIG_PREFIX}/${CMAKE_INSTALL_BINDIR}" + CACHE INTERNAL + "" + ) + set( + _PKG_CONFIG_PKGLIBDIR + "${_PKG_CONFIG_PREFIX}/${CMAKE_INSTALL_PKGLIBDIR}" + CACHE INTERNAL + "" + ) + set( + _PKG_CONFIG_INCLUDEDIR + "${_PKG_CONFIG_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}" + CACHE INTERNAL + "" + ) + set( + _PKG_CONFIG_DATAROOTDIR + "${_PKG_CONFIG_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}" + CACHE INTERNAL + "" + ) + set( + _PKG_CONFIG_PKGDATAROOTDIR + "${_PKG_CONFIG_PREFIX}/${CMAKE_INSTALL_DATADIR}" + CACHE INTERNAL + "" + ) if(INSTALL_DOCUMENTATION) - set(_PKG_CONFIG_DOCDIR - "${_PKG_CONFIG_PREFIX}/${CMAKE_INSTALL_DOCDIR}" - CACHE INTERNAL "") - set(_PKG_CONFIG_DOXYGENDOCDIR - "${_PKG_CONFIG_DOCDIR}/doxygen-html" - CACHE INTERNAL "") + set( + _PKG_CONFIG_DOCDIR + "${_PKG_CONFIG_PREFIX}/${CMAKE_INSTALL_DOCDIR}" + CACHE INTERNAL + "" + ) + set( + _PKG_CONFIG_DOXYGENDOCDIR + "${_PKG_CONFIG_DOCDIR}/doxygen-html" + CACHE INTERNAL + "" + ) else(INSTALL_DOCUMENTATION) - set(_PKG_CONFIG_DOCDIR - "" - CACHE INTERNAL "") - set(_PKG_CONFIG_DOXYGENDOCDIR - "" - CACHE INTERNAL "") + set(_PKG_CONFIG_DOCDIR "" CACHE INTERNAL "") + set(_PKG_CONFIG_DOXYGENDOCDIR "" CACHE INTERNAL "") endif(INSTALL_DOCUMENTATION) if(DEFINED PROJECT_DEBUG_POSTFIX) if(DEFINED CMAKE_CONFIGURATION_TYPES) - set(_PKG_CONFIG_PROJECT_NAME_NOPOSTFIX - "${PROJECT_NAME}" - CACHE INTERNAL "") - set(_PKG_CONFIG_PROJECT_NAME - "${PROJECT_NAME}${PKGCONFIG_POSTFIX}" - CACHE INTERNAL "") + set( + _PKG_CONFIG_PROJECT_NAME_NOPOSTFIX + "${PROJECT_NAME}" + CACHE INTERNAL + "" + ) + set( + _PKG_CONFIG_PROJECT_NAME + "${PROJECT_NAME}${PKGCONFIG_POSTFIX}" + CACHE INTERNAL + "" + ) else() - set(_PKG_CONFIG_PROJECT_NAME - "${PROJECT_NAME}${PKGCONFIG_POSTFIX}" - CACHE INTERNAL "") + set( + _PKG_CONFIG_PROJECT_NAME + "${PROJECT_NAME}${PKGCONFIG_POSTFIX}" + CACHE INTERNAL + "" + ) endif() else() - set(_PKG_CONFIG_PROJECT_NAME - "${PROJECT_NAME}" - CACHE INTERNAL "") + set(_PKG_CONFIG_PROJECT_NAME "${PROJECT_NAME}" CACHE INTERNAL "") endif() - set(_PKG_CONFIG_DESCRIPTION - "${PROJECT_DESCRIPTION}" - CACHE INTERNAL "") - set(_PKG_CONFIG_URL - "${PROJECT_URL}" - CACHE INTERNAL "") - set(_PKG_CONFIG_VERSION - "${PROJECT_VERSION}" - CACHE INTERNAL "") - set(_PKG_CONFIG_REQUIRES - "" - CACHE INTERNAL "") - set(_PKG_CONFIG_REQUIRES_DEBUG - "" - CACHE INTERNAL "") - set(_PKG_CONFIG_REQUIRES_OPTIMIZED - "" - CACHE INTERNAL "") - set(_PKG_CONFIG_COMPILE_TIME_REQUIRES - "" - CACHE INTERNAL "") - set(_PKG_CONFIG_CONFLICTS - "" - CACHE INTERNAL "") - set(_PKG_CONFIG_LIBS - "" - CACHE INTERNAL "") - set(_PKG_CONFIG_LIBS_DEBUG - "${LIBDIR_KW}\${libdir}" - CACHE INTERNAL "") - set(_PKG_CONFIG_LIBS_OPTIMIZED - "${LIBDIR_KW}\${libdir}" - CACHE INTERNAL "") - set(_PKG_CONFIG_LIBS_PRIVATE - "" - CACHE INTERNAL "") - set(_PKG_CONFIG_CFLAGS - "-I\${includedir}" - CACHE INTERNAL "") - set(_PKG_CONFIG_CFLAGS_DEBUG - "" - CACHE INTERNAL "") - set(_PKG_CONFIG_CFLAGS_OPTIMIZED - "" - CACHE INTERNAL "") - set(_PKG_CONFIG_FILENAME - "${PROJECT_NAME}.pc" - CACHE INTERNAL "") + set(_PKG_CONFIG_DESCRIPTION "${PROJECT_DESCRIPTION}" CACHE INTERNAL "") + set(_PKG_CONFIG_URL "${PROJECT_URL}" CACHE INTERNAL "") + set(_PKG_CONFIG_VERSION "${PROJECT_VERSION}" CACHE INTERNAL "") + set(_PKG_CONFIG_REQUIRES "" CACHE INTERNAL "") + set(_PKG_CONFIG_REQUIRES_DEBUG "" CACHE INTERNAL "") + set(_PKG_CONFIG_REQUIRES_OPTIMIZED "" CACHE INTERNAL "") + set(_PKG_CONFIG_COMPILE_TIME_REQUIRES "" CACHE INTERNAL "") + set(_PKG_CONFIG_CONFLICTS "" CACHE INTERNAL "") + set(_PKG_CONFIG_LIBS "" CACHE INTERNAL "") + set(_PKG_CONFIG_LIBS_DEBUG "${LIBDIR_KW}\${libdir}" CACHE INTERNAL "") + set(_PKG_CONFIG_LIBS_OPTIMIZED "${LIBDIR_KW}\${libdir}" CACHE INTERNAL "") + set(_PKG_CONFIG_LIBS_PRIVATE "" CACHE INTERNAL "") + set(_PKG_CONFIG_CFLAGS "-I\${includedir}" CACHE INTERNAL "") + set(_PKG_CONFIG_CFLAGS_DEBUG "" CACHE INTERNAL "") + set(_PKG_CONFIG_CFLAGS_OPTIMIZED "" CACHE INTERNAL "") + set(_PKG_CONFIG_FILENAME "${PROJECT_NAME}.pc" CACHE INTERNAL "") set(PKG_CONFIG_EXTRA "") # Where to install the pkg-config file? - set(_PKG_CONFIG_DIR - "${_PKG_CONFIG_LIBDIR}/pkgconfig" - CACHE INTERNAL "") + set(_PKG_CONFIG_DIR "${_PKG_CONFIG_LIBDIR}/pkgconfig" CACHE INTERNAL "") # Watch variables. list( @@ -201,7 +200,8 @@ macro(_SETUP_PROJECT_PKG_CONFIG) _PKG_CONFIG_CFLAGS_DEBUG _PKG_CONFIG_CFLAGS_OPTIMIZED _PKG_CONFIG_FILENAME - PKG_CONFIG_EXTRA) + PKG_CONFIG_EXTRA + ) endmacro(_SETUP_PROJECT_PKG_CONFIG) # _SETUP_PROJECT_PKG_CONFIG_FINALIZE_DEBUG @@ -228,7 +228,8 @@ macro(_SETUP_PROJECT_PKG_CONFIG_FINALIZE_DEBUG) _list_join(_PKG_CONFIG_REQUIRES ", " _PKG_CONFIG_REQUIRES_LIST) configure_file( "${PROJECT_JRL_CMAKE_MODULE_DIR}/pkg-config.pc.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}${PKGCONFIG_POSTFIX}.pc") + "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}${PKGCONFIG_POSTFIX}.pc" + ) # Restore altered variables set(_PKG_CONFIG_CFLAGS ${TEMP_CFLAGS}) set(_PKG_CONFIG_LIBS ${TEMP_LIBS}) @@ -237,7 +238,8 @@ macro(_SETUP_PROJECT_PKG_CONFIG_FINALIZE_DEBUG) install( FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}${PKGCONFIG_POSTFIX}.pc" DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig - PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE) + PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE + ) endmacro(_SETUP_PROJECT_PKG_CONFIG_FINALIZE_DEBUG) # _SETUP_PROJECT_PKG_CONFIG_FINALIZE_OPTIMIZED @@ -256,8 +258,10 @@ macro(_SETUP_PROJECT_PKG_CONFIG_FINALIZE_OPTIMIZED) set(TEMP_PROJECT_NAME ${_PKG_CONFIG_PROJECT_NAME}) set(_PKG_CONFIG_PROJECT_NAME ${_PKG_CONFIG_PROJECT_NAME_NOPOSTFIX}) set(TEMP_CFLAGS ${_PKG_CONFIG_CFLAGS}) - set(_PKG_CONFIG_CFLAGS - "${_PKG_CONFIG_CFLAGS_OPTIMIZED} ${_PKG_CONFIG_CFLAGS}") + set( + _PKG_CONFIG_CFLAGS + "${_PKG_CONFIG_CFLAGS_OPTIMIZED} ${_PKG_CONFIG_CFLAGS}" + ) set(TEMP_LIBS ${_PKG_CONFIG_LIBS}) set(_PKG_CONFIG_LIBS "${_PKG_CONFIG_LIBS_OPTIMIZED} ${_PKG_CONFIG_LIBS}") set(TEMP_REQUIRES ${_PKG_CONFIG_REQUIRES}) @@ -266,13 +270,18 @@ macro(_SETUP_PROJECT_PKG_CONFIG_FINALIZE_OPTIMIZED) endif() _list_join(_PKG_CONFIG_REQUIRES ", " _PKG_CONFIG_REQUIRES_LIST) if(DEFINED CUSTOM_PKG_CONFIG_FILENAME) - set(_PKG_CONFIG_FILENAME - "${CUSTOM_PKG_CONFIG_FILENAME}.pc" - CACHE INTERNAL "") + set( + _PKG_CONFIG_FILENAME + "${CUSTOM_PKG_CONFIG_FILENAME}.pc" + CACHE INTERNAL + "" + ) endif(DEFINED CUSTOM_PKG_CONFIG_FILENAME) # Generate the pkg-config file. - configure_file("${PROJECT_JRL_CMAKE_MODULE_DIR}/pkg-config.pc.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/${_PKG_CONFIG_FILENAME}") + configure_file( + "${PROJECT_JRL_CMAKE_MODULE_DIR}/pkg-config.pc.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/${_PKG_CONFIG_FILENAME}" + ) # Restore altered variables set(_PKG_CONFIG_PROJECT_NAME ${TEMP_PROJECT_NAME}) set(_PKG_CONFIG_CFLAGS ${TEMP_CFLAGS}) @@ -282,7 +291,8 @@ macro(_SETUP_PROJECT_PKG_CONFIG_FINALIZE_OPTIMIZED) install( FILES "${CMAKE_CURRENT_BINARY_DIR}/${_PKG_CONFIG_FILENAME}" DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig - PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE) + PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE + ) endmacro(_SETUP_PROJECT_PKG_CONFIG_FINALIZE_OPTIMIZED) # _SETUP_PROJECT_PKG_CONFIG_FINALIZE @@ -324,20 +334,36 @@ endmacro(_SETUP_PROJECT_PKG_CONFIG_FINALIZE) # _PKG_PREFIX_VAR <- MY_PACKAGE - _PKG_CONFIG_STRING_NOSPACE_VAR <- # `my-package>0.4` `my-package` results in - _PKG_LIB_NAME_VAR <- my-package - # _PKG_PREFIX_VAR <- MY_PACKAGE - _PKG_CONFIG_STRING_NOSPACE_VAR <- `my-package` -macro(_PARSE_PKG_CONFIG_STRING PKG_CONFIG_STRING _PKG_LIB_NAME_VAR - _PKG_PREFIX_VAR _PKG_CONFIG_NOSPACE_VAR) +macro( + _PARSE_PKG_CONFIG_STRING + PKG_CONFIG_STRING + _PKG_LIB_NAME_VAR + _PKG_PREFIX_VAR + _PKG_CONFIG_NOSPACE_VAR +) # Decompose the equation - string(REGEX MATCH "([^ ]+)( (>|>=|=|<=|<) (.*))?" _UNUSED - "${PKG_CONFIG_STRING}") + string( + REGEX MATCH + "([^ ]+)( (>|>=|=|<=|<) (.*))?" + _UNUSED + "${PKG_CONFIG_STRING}" + ) # Reconstruct the equation, without the space around the operator - set(${_PKG_CONFIG_NOSPACE_VAR} - "${CMAKE_MATCH_1}${CMAKE_MATCH_3}${CMAKE_MATCH_4}") + set( + ${_PKG_CONFIG_NOSPACE_VAR} + "${CMAKE_MATCH_1}${CMAKE_MATCH_3}${CMAKE_MATCH_4}" + ) # The left part of the equation is the package name set(${_PKG_LIB_NAME_VAR} "${CMAKE_MATCH_1}") # Transform it into a valid variable prefix. 1. replace invalid characters # into underscores. - string(REGEX REPLACE "[^a-zA-Z0-9]" "_" ${_PKG_PREFIX_VAR} - "${${_PKG_LIB_NAME_VAR}}") + string( + REGEX REPLACE + "[^a-zA-Z0-9]" + "_" + ${_PKG_PREFIX_VAR} + "${${_PKG_LIB_NAME_VAR}}" + ) # 1. make it uppercase. string(TOUPPER "${${_PKG_PREFIX_VAR}}" ${_PKG_PREFIX_VAR}) endmacro() @@ -358,13 +384,20 @@ endmacro() # PKG_CONFIG_STRING : string passed to pkg-config to check the version. # Typically, this string looks like: ``my-package >= 0.5'' # -macro(ADD_DEPENDENCY P_REQUIRED COMPILE_TIME_ONLY PKG_CONFIG_STRING - PKG_CONFIG_DEBUG_STRING) +macro( + ADD_DEPENDENCY + P_REQUIRED + COMPILE_TIME_ONLY + PKG_CONFIG_STRING + PKG_CONFIG_DEBUG_STRING +) _parse_pkg_config_string("${PKG_CONFIG_STRING}" LIBRARY_NAME PREFIX - PKG_CONFIG_STRING_NOSPACE) + PKG_CONFIG_STRING_NOSPACE + ) if(NOT ${PKG_CONFIG_DEBUG_STRING} STREQUAL "") _parse_pkg_config_string("${PKG_CONFIG_DEBUG_STRING}" LIBRARY_DEBUG_NAME - ${PREFIX}_DEBUG PKG_CONFIG_DEBUG_STRING_NOSPACE) + ${PREFIX}_DEBUG PKG_CONFIG_DEBUG_STRING_NOSPACE + ) endif() # Force redetection each time CMake is launched. Rationale: these values are @@ -407,8 +440,11 @@ macro(ADD_DEPENDENCY P_REQUIRED COMPILE_TIME_ONLY PKG_CONFIG_STRING if(DEFINED ${PREFIX}_DEBUG) if(${P_DEBUG_REQUIRED}) message(STATUS "${PKG_CONFIG_DEBUG_STRING} is required") - pkg_check_modules("${PREFIX}_DEBUG" REQUIRED - "${PKG_CONFIG_DEBUG_STRING_NOSPACE}") + pkg_check_modules( + "${PREFIX}_DEBUG" + REQUIRED + "${PKG_CONFIG_DEBUG_STRING_NOSPACE}" + ) else(${P_DEBUG_REQUIRED}) message(STATUS "${PKG_CONFIG_DEBUG_STRING} is optional") pkg_check_modules("${PREFIX}_DEBUG" "${PKG_CONFIG_DEBUG_STRING_NOSPACE}") @@ -422,10 +458,20 @@ macro(ADD_DEPENDENCY P_REQUIRED COMPILE_TIME_ONLY PKG_CONFIG_STRING string(REPLACE "-l:/" "/" "${PREFIX}_LDFLAGS" "${${PREFIX}_LDFLAGS}") if(DEFINED ${PREFIX}_DEBUG) - string(REPLACE ":/" "/" "${PREFIX}_DEBUG_LIBRARIES" - "${${PREFIX}_DEBUG_LIBRARIES}") - string(REPLACE "-l:/" "/" "${PREFIX}_DEBUG_LDFLAGS" - "${${PREFIX}_DEBUG_LDFLAGS}") + string( + REPLACE + ":/" + "/" + "${PREFIX}_DEBUG_LIBRARIES" + "${${PREFIX}_DEBUG_LIBRARIES}" + ) + string( + REPLACE + "-l:/" + "/" + "${PREFIX}_DEBUG_LDFLAGS" + "${${PREFIX}_DEBUG_LDFLAGS}" + ) endif() endif() @@ -452,7 +498,8 @@ macro(ADD_DEPENDENCY P_REQUIRED COMPILE_TIME_ONLY PKG_CONFIG_STRING ${PREFIX}_DATAROOTDIR ${PREFIX}_PKGDATAROOTDIR ${PREFIX}_DOCDIR - ${PREFIX}_DOXYGENDOCDIR) + ${PREFIX}_DOXYGENDOCDIR + ) if(DEFINED ${PREFIX}_DEBUG) list( APPEND @@ -476,7 +523,8 @@ macro(ADD_DEPENDENCY P_REQUIRED COMPILE_TIME_ONLY PKG_CONFIG_STRING ${PREFIX}_DEBUG_DATAROOTDIR ${PREFIX}_DEBUG_PKGDATAROOTDIR ${PREFIX}_DEBUG_DOCDIR - ${PREFIX}_DEBUG_DOXYGENDOCDIR) + ${PREFIX}_DEBUG_DOXYGENDOCDIR + ) endif() # Get the values of additional variables. @@ -484,22 +532,35 @@ macro(ADD_DEPENDENCY P_REQUIRED COMPILE_TIME_ONLY PKG_CONFIG_STRING # Upper-case version of the variable for CMake variable generation. string(TOUPPER "${VARIABLE}" "VARIABLE_UC") execute_process( - COMMAND "${PKG_CONFIG_EXECUTABLE}" "--variable=${VARIABLE}" - "${LIBRARY_NAME}" + COMMAND + "${PKG_CONFIG_EXECUTABLE}" "--variable=${VARIABLE}" "${LIBRARY_NAME}" OUTPUT_VARIABLE "${PREFIX}_${VARIABLE_UC}" - ERROR_QUIET) - string(REPLACE "\n" "" "${PREFIX}_${VARIABLE_UC}" - "${${PREFIX}_${VARIABLE_UC}}") + ERROR_QUIET + ) + string( + REPLACE + "\n" + "" + "${PREFIX}_${VARIABLE_UC}" + "${${PREFIX}_${VARIABLE_UC}}" + ) # Watch additional variables. list(APPEND LOGGING_WATCHED_VARIABLES ${PREFIX}_${VARIABLE_UC}) if(DEFINED ${PREFIX}_DEBUG) execute_process( - COMMAND "${PKG_CONFIG_EXECUTABLE}" "--variable=${VARIABLE}" - "${LIBRARY_DEBUG_NAME}" + COMMAND + "${PKG_CONFIG_EXECUTABLE}" "--variable=${VARIABLE}" + "${LIBRARY_DEBUG_NAME}" OUTPUT_VARIABLE "${PREFIX}_DEBUG_${VARIABLE_UC}" - ERROR_QUIET) - string(REPLACE "\n" "" "${PREFIX}_DEBUG_${VARIABLE_UC}" - "${${PREFIX}_DEBUG_${VARIABLE_UC}}") + ERROR_QUIET + ) + string( + REPLACE + "\n" + "" + "${PREFIX}_DEBUG_${VARIABLE_UC}" + "${${PREFIX}_DEBUG_${VARIABLE_UC}}" + ) list(APPEND LOGGING_WATCHED_VARIABLES ${PREFIX}_DEBUG_${VARIABLE_UC}) endif() endforeach(VARIABLE) @@ -533,25 +594,29 @@ macro(ADD_DEPENDENCY P_REQUIRED COMPILE_TIME_ONLY PKG_CONFIG_STRING if(NOT ${COMPILE_TIME_ONLY}) if(DEFINED PROJECT_DEBUG_POSTFIX AND DEFINED ${PREFIX}_DEBUG) _add_to_list_if_not_present(_PKG_CONFIG_REQUIRES_DEBUG - "${PKG_CONFIG_DEBUG_STRING}") + "${PKG_CONFIG_DEBUG_STRING}" + ) _add_to_list_if_not_present(_PKG_CONFIG_REQUIRES_OPTIMIZED - "${PKG_CONFIG_STRING}") + "${PKG_CONFIG_STRING}" + ) else() # Warn the user in case he/she is using alternative libraries for debug # but no postfix if(NOT DEFINED PROJECT_DEBUG_POSTFIX AND DEFINED ${PREFIX}_DEBUG) message( AUTHOR_WARNING - "You are linking with different libraries in debug mode but the + "You are linking with different libraries in debug mode but the generated .pc cannot reflect that, it will default to release flags. Consider setting PROJECT_DEBUG_POSTFIX to generate different libraries and pc files in - debug mode.") + debug mode." + ) endif() _add_to_list_if_not_present(_PKG_CONFIG_REQUIRES "${PKG_CONFIG_STRING}") endif() else() _add_to_list_if_not_present(_PKG_CONFIG_COMPILE_TIME_REQUIRES - "${PKG_CONFIG_STRING}") + "${PKG_CONFIG_STRING}" + ) endif() endif() @@ -562,16 +627,19 @@ macro(ADD_DEPENDENCY P_REQUIRED COMPILE_TIME_ONLY PKG_CONFIG_STRING endif(COMMAND ADD_CMAKE_DEPENDENCY) if(${${PREFIX}_FOUND}) - message(STATUS "Pkg-config module ${LIBRARY_NAME} v${${PREFIX}_VERSION}" - " has been detected with success.") + message( + STATUS + "Pkg-config module ${LIBRARY_NAME} v${${PREFIX}_VERSION}" + " has been detected with success." + ) endif() if(DEFINED ${PREFIX}_DEBUG AND "${${PREFIX}_DEBUG_FOUND}") message( STATUS - "Pkg-config module ${LIBRARY_DEBUG_NAME} v${${PREFIX}_DEBUG_VERSION}" - " has been detected with success.") + "Pkg-config module ${LIBRARY_DEBUG_NAME} v${${PREFIX}_DEBUG_VERSION}" + " has been detected with success." + ) endif() - endmacro(ADD_DEPENDENCY) # .rst: .. ifmode:: internal @@ -587,13 +655,19 @@ macro(_GET_PKG_CONFIG_DEBUG_STRING PKG_CONFIG_STRING) foreach(ARG ${ARGN}) set(PKG_CONFIG_DEBUG_STRING ${ARG}) endforeach() - if(WIN32 - AND DEFINED PROJECT_DEBUG_POSTFIX - AND "${PKG_CONFIG_DEBUG_STRING}" STREQUAL "") + if( + WIN32 + AND DEFINED PROJECT_DEBUG_POSTFIX + AND "${PKG_CONFIG_DEBUG_STRING}" STREQUAL "" + ) _parse_pkg_config_string("${PKG_CONFIG_STRING}" LIBRARY_NAME PREFIX) - string(REGEX - REPLACE "${LIBRARY_NAME}" "${LIBRARY_NAME}${PROJECT_DEBUG_POSTFIX}" - LIBRARY_NAME "${PKG_CONFIG_STRING}") + string( + REGEX REPLACE + "${LIBRARY_NAME}" + "${LIBRARY_NAME}${PROJECT_DEBUG_POSTFIX}" + LIBRARY_NAME + "${PKG_CONFIG_STRING}" + ) pkg_check_modules("${PREFIX}" "${LIBRARY_NAME}") if(${PREFIX}_FOUND) set(PKG_CONFIG_DEBUG_STRING "${LIBRARY_NAME}") @@ -693,9 +767,12 @@ endmacro(ADD_DOC_DEPENDENCY) macro(PKG_CONFIG_APPEND_LIBRARY_DIR DIRS) foreach(DIR ${DIRS}) if(DIR) - set(_PKG_CONFIG_LIBS - "${_PKG_CONFIG_LIBS} ${LIBDIR_KW}${DIR}" - CACHE INTERNAL "") + set( + _PKG_CONFIG_LIBS + "${_PKG_CONFIG_LIBS} ${LIBDIR_KW}${DIR}" + CACHE INTERNAL + "" + ) endif(DIR) endforeach(DIR ${DIRS}) endmacro(PKG_CONFIG_APPEND_LIBRARY_DIR DIR) @@ -713,14 +790,17 @@ macro(PKG_CONFIG_APPEND_CFLAGS_DEBUG FLAGS) if(NOT DEFINED PROJECT_DEBUG_POSTFIX) message( FATAL_ERROR - "You are trying to use PKG_CONFIG_APPEND_CFLAGS_DEBUG on a package that does not have a debug library" + "You are trying to use PKG_CONFIG_APPEND_CFLAGS_DEBUG on a package that does not have a debug library" ) endif() foreach(FLAG ${FLAGS}) if(FLAG) - set(_PKG_CONFIG_CFLAGS_DEBUG - "${_PKG_CONFIG_CFLAGS_DEBUG} ${FLAG}" - CACHE INTERNAL "") + set( + _PKG_CONFIG_CFLAGS_DEBUG + "${_PKG_CONFIG_CFLAGS_DEBUG} ${FLAG}" + CACHE INTERNAL + "" + ) endif(FLAG) endforeach(FLAG ${FLAGS}) endmacro(PKG_CONFIG_APPEND_CFLAGS_DEBUG FLAGS) @@ -738,14 +818,17 @@ macro(PKG_CONFIG_APPEND_CFLAGS_OPTIMIZED FLAGS) if(NOT DEFINED PROJECT_DEBUG_POSTFIX) message( FATAL_ERROR - "You are trying to use PKG_CONFIG_APPEND_CFLAGS_OPTIMIZED on a package that does not have a debug library" + "You are trying to use PKG_CONFIG_APPEND_CFLAGS_OPTIMIZED on a package that does not have a debug library" ) endif() foreach(FLAG ${FLAGS}) if(FLAG) - set(_PKG_CONFIG_CFLAGS_OPTIMIZED - "${_PKG_CONFIG_CFLAGS_OPTIMIZED} ${FLAG}" - CACHE INTERNAL "") + set( + _PKG_CONFIG_CFLAGS_OPTIMIZED + "${_PKG_CONFIG_CFLAGS_OPTIMIZED} ${FLAG}" + CACHE INTERNAL + "" + ) endif(FLAG) endforeach(FLAG ${FLAGS}) endmacro(PKG_CONFIG_APPEND_CFLAGS_OPTIMIZED FLAGS) @@ -759,9 +842,7 @@ endmacro(PKG_CONFIG_APPEND_CFLAGS_OPTIMIZED FLAGS) macro(PKG_CONFIG_APPEND_CFLAGS FLAGS) foreach(FLAG ${FLAGS}) if(FLAG) - set(_PKG_CONFIG_CFLAGS - "${_PKG_CONFIG_CFLAGS} ${FLAG}" - CACHE INTERNAL "") + set(_PKG_CONFIG_CFLAGS "${_PKG_CONFIG_CFLAGS} ${FLAG}" CACHE INTERNAL "") endif(FLAG) endforeach(FLAG ${FLAGS}) endmacro(PKG_CONFIG_APPEND_CFLAGS) @@ -790,13 +871,14 @@ macro(PKG_CONFIG_APPEND_LIBS_RAW LIBS) if(APPLE AND ${LIB} MATCHES "\\.framework") get_filename_component(framework_PATH ${LIB} PATH) get_filename_component(framework_NAME ${LIB} NAME_WE) - set(_PKG_CONFIG_LIBS - "${_PKG_CONFIG_LIBS} -F${framework_PATH} -Wl,-framework,${framework_NAME}" - CACHE INTERNAL "") + set( + _PKG_CONFIG_LIBS + "${_PKG_CONFIG_LIBS} -F${framework_PATH} -Wl,-framework,${framework_NAME}" + CACHE INTERNAL + "" + ) else(APPLE AND ${LIB} MATCHES "\\.framework") - set(_PKG_CONFIG_LIBS - "${_PKG_CONFIG_LIBS} ${LIB}" - CACHE INTERNAL "") + set(_PKG_CONFIG_LIBS "${_PKG_CONFIG_LIBS} ${LIB}" CACHE INTERNAL "") endif(APPLE AND ${LIB} MATCHES "\\.framework") endif(LIB) endforeach(LIB ${LIBS}) @@ -848,26 +930,19 @@ macro(PKG_CONFIG_APPEND_LIBS LIBS) OUTPUT_NAME_SET TARGET ${LIB} PROPERTY ${OUTPUT_NAME_FIX} - SET) + SET + ) if(OUTPUT_NAME_SET) get_target_property(OUTPUT_LIB_NAME ${LIB} ${OUTPUT_NAME_FIX}) endif(OUTPUT_NAME_SET) # If SUFFIX property is defined, use it for defining the library name. - get_property( - SUFFIX_SET - TARGET ${LIB} - PROPERTY ${SUFFIX_FIX} - SET) + get_property(SUFFIX_SET TARGET ${LIB} PROPERTY ${SUFFIX_FIX} SET) if(SUFFIX_SET) get_target_property(LIB_SUFFIX ${LIB} ${SUFFIX_FIX}) endif(SUFFIX_SET) - get_property( - PREFIX_SET - TARGET ${LIB} - PROPERTY ${PREFIX_FIX} - SET) + get_property(PREFIX_SET TARGET ${LIB} PROPERTY ${PREFIX_FIX} SET) if(PREFIX_SET) get_target_property(LIB_PREFIX ${LIB} ${PREFIX_FIX}) endif(PREFIX_SET) @@ -883,31 +958,44 @@ macro(PKG_CONFIG_APPEND_LIBS LIBS) endif(UNIX OR APPLE) # Single build type generator if(DEFINED CMAKE_BUILD_TYPE) - set(_PKG_CONFIG_LIBS - "${_PKG_CONFIG_LIBS} ${LIBINCL_KW}${LIB_COMPLETE_NAME}${PKGCONFIG_POSTFIX}${LIB_EXT}" - CACHE INTERNAL "") + set( + _PKG_CONFIG_LIBS + "${_PKG_CONFIG_LIBS} ${LIBINCL_KW}${LIB_COMPLETE_NAME}${PKGCONFIG_POSTFIX}${LIB_EXT}" + CACHE INTERNAL + "" + ) # Multiple build types generator else() - set(_PKG_CONFIG_LIBS_DEBUG - "${_PKG_CONFIG_LIBS_DEBUG} ${LIBINCL_KW}${LIB_COMPLETE_NAME}${PKGCONFIG_POSTFIX}${LIB_EXT}" - CACHE INTERNAL "") - string(STRIP ${_PKG_CONFIG_LIBS_DEBUG} _PKG_CONFIG_LIBS_DEBUG - )# To address CMP0004 - set(_PKG_CONFIG_LIBS_OPTIMIZED - "${_PKG_CONFIG_LIBS_OPTIMIZED} ${LIBINCL_KW}${LIB_COMPLETE_NAME}${LIB_EXT}" - CACHE INTERNAL "") - string(STRIP ${_PKG_CONFIG_LIBS_OPTIMIZED} _PKG_CONFIG_LIBS_OPTIMIZED - )# To address CMP0004 + set( + _PKG_CONFIG_LIBS_DEBUG + "${_PKG_CONFIG_LIBS_DEBUG} ${LIBINCL_KW}${LIB_COMPLETE_NAME}${PKGCONFIG_POSTFIX}${LIB_EXT}" + CACHE INTERNAL + "" + ) + string(STRIP ${_PKG_CONFIG_LIBS_DEBUG} _PKG_CONFIG_LIBS_DEBUG) # To address CMP0004 + set( + _PKG_CONFIG_LIBS_OPTIMIZED + "${_PKG_CONFIG_LIBS_OPTIMIZED} ${LIBINCL_KW}${LIB_COMPLETE_NAME}${LIB_EXT}" + CACHE INTERNAL + "" + ) + string(STRIP ${_PKG_CONFIG_LIBS_OPTIMIZED} _PKG_CONFIG_LIBS_OPTIMIZED) # To address CMP0004 endif() else() if(IS_ABSOLUTE ${LIB}) - set(_PKG_CONFIG_LIBS - "${_PKG_CONFIG_LIBS} ${LIBINCL_ABSKW}${LIB}" - CACHE INTERNAL "") + set( + _PKG_CONFIG_LIBS + "${_PKG_CONFIG_LIBS} ${LIBINCL_ABSKW}${LIB}" + CACHE INTERNAL + "" + ) else() - set(_PKG_CONFIG_LIBS - "${_PKG_CONFIG_LIBS} ${LIBINCL_KW}${LIB}${LIB_EXT}" - CACHE INTERNAL "") + set( + _PKG_CONFIG_LIBS + "${_PKG_CONFIG_LIBS} ${LIBINCL_KW}${LIB}${LIB_EXT}" + CACHE INTERNAL + "" + ) endif() string(STRIP ${_PKG_CONFIG_LIBS} _PKG_CONFIG_LIBS) # To address CMP0004 endif() @@ -927,14 +1015,15 @@ endmacro(PKG_CONFIG_APPEND_LIBS) # I.e. PKG_CONFIG_USE_LCOMPILE_DEPENDENCY(my-binary my-package) # macro(PKG_CONFIG_USE_LCOMPILE_DEPENDENCY TARGET PREFIX NO_INCLUDE_SYSTEM) - if(DEFINED ${PREFIX}_DEBUG_FOUND) foreach(FLAG ${${PREFIX}_DEBUG_CFLAGS_OTHER}) target_compile_options(${TARGET} PUBLIC "$<$:${FLAG}>") endforeach() foreach(FLAG ${${PREFIX}_CFLAGS_OTHER}) - target_compile_options(${TARGET} - PUBLIC "$<$>:${FLAG}>") + target_compile_options( + ${TARGET} + PUBLIC "$<$>:${FLAG}>" + ) endforeach() else() foreach(FLAG ${${PREFIX}_CFLAGS_OTHER}) @@ -952,21 +1041,30 @@ macro(PKG_CONFIG_USE_LCOMPILE_DEPENDENCY TARGET PREFIX NO_INCLUDE_SYSTEM) set(SYSTEM "") endif() - target_include_directories(${TARGET} ${SYSTEM} ${SCOPE} - ${${PREFIX}_INCLUDE_DIRS}) + target_include_directories( + ${TARGET} + ${SYSTEM} + ${SCOPE} + ${${PREFIX}_INCLUDE_DIRS} + ) if(DEFINED ${PREFIX}_DEBUG_FOUND) - target_include_directories(${TARGET} ${SYSTEM} ${SCOPE} - ${${PREFIX}_DEBUG_INCLUDE_DIRS}) + target_include_directories( + ${TARGET} + ${SYSTEM} + ${SCOPE} + ${${PREFIX}_DEBUG_INCLUDE_DIRS} + ) endif() - endmacro(PKG_CONFIG_USE_LCOMPILE_DEPENDENCY) macro(_FILTER_LINK_FLAGS TARGET IS_GENERAL IS_DEBUG FLAGS) foreach(FLAG ${FLAGS}) string(FIND "${FLAG}" "/" STARTS_WITH_SLASH) string(FIND "${FLAG}" "-" STARTS_WITH_DASH) - if(NOT WIN32 OR (NOT ${STARTS_WITH_DASH} EQUAL 0 - AND NOT ${STARTS_WITH_SLASH} EQUAL 0)) + if( + NOT WIN32 + OR (NOT ${STARTS_WITH_DASH} EQUAL 0 AND NOT ${STARTS_WITH_SLASH} EQUAL 0) + ) if(${IS_GENERAL}) target_link_libraries(${TARGET} ${PUBLIC_KEYWORD} ${FLAG}) elseif(${IS_DEBUG}) @@ -981,7 +1079,14 @@ endmacro() # Internal use only. _PKG_CONFIG_MANIPULATE_LDFLAGS(TARGET PREFIX CONFIG # IS_GENERAL IS_DEBUG) # -macro(_PKG_CONFIG_MANIPULATE_LDFLAGS TARGET PREFIX CONFIG IS_GENERAL IS_DEBUG) +macro( + _PKG_CONFIG_MANIPULATE_LDFLAGS + TARGET + PREFIX + CONFIG + IS_GENERAL + IS_DEBUG +) # Make sure we do not override previous flags get_target_property(LDFLAGS ${TARGET} LINK_FLAGS${CONFIG}) @@ -1000,14 +1105,16 @@ macro(_PKG_CONFIG_MANIPULATE_LDFLAGS TARGET PREFIX CONFIG IS_GENERAL IS_DEBUG) set_target_properties(${TARGET} PROPERTIES LINK_FLAGS${CONFIG} "${LDFLAGS}") _filter_link_flags(${TARGET} ${IS_GENERAL} ${IS_DEBUG} "${${PREFIX}_LDFLAGS}") _filter_link_flags(${TARGET} ${IS_GENERAL} ${IS_DEBUG} - "${${PREFIX}_LDFLAGS_OTHER}") + "${${PREFIX}_LDFLAGS_OTHER}" + ) endmacro( _PKG_CONFIG_MANIPULATE_LDFLAGS TARGET PREFIX CONFIG IS_GENERAL - IS_DEBUG) + IS_DEBUG +) # Internal use only. PKG_CONFIG_USE_LLINK_DEPENDENCY(TARGET DEPENDENCY) # -------------------------------------------- @@ -1020,7 +1127,6 @@ endmacro( # I.e. PKG_CONFIG_USE_LLINK_DEPENDENCY(my-binary my-package) # macro(PKG_CONFIG_USE_LLINK_DEPENDENCY TARGET PREFIX) - if(NOT DEFINED ${PREFIX}_DEBUG_FOUND) _pkg_config_manipulate_ldflags(${TARGET} ${PREFIX} "" 1 0) else() @@ -1038,10 +1144,12 @@ macro(PKG_CONFIG_USE_LLINK_DEPENDENCY TARGET PREFIX) string(TOUPPER "_${config}" config_in) if(${config_in} MATCHES "_DEBUG") _pkg_config_manipulate_ldflags(${TARGET} "${PREFIX}_DEBUG" - "${config_in}" 0 1) + "${config_in}" 0 1 + ) else() _pkg_config_manipulate_ldflags(${TARGET} "${PREFIX}" "${config_in}" 0 - 0) + 0 + ) endif() endforeach() endif() @@ -1052,11 +1160,9 @@ macro(PKG_CONFIG_USE_LLINK_DEPENDENCY TARGET PREFIX) if(DEFINED ${PREFIX}_DEBUG_FOUND) link_directories(${${PREFIX}_DEBUG_LIBRARY_DIRS}) endif() - endmacro(PKG_CONFIG_USE_LLINK_DEPENDENCY) macro(BUILD_PREFIX_FOR_PKG DEPENDENCY PREFIX) - # Transform the dependency into a valid variable prefix. 1. replace invalid # characters into underscores. string(REGEX REPLACE "[^a-zA-Z0-9]" "_" LPREFIX "${DEPENDENCY}") @@ -1067,15 +1173,15 @@ macro(BUILD_PREFIX_FOR_PKG DEPENDENCY PREFIX) if(NOT DEFINED ${LPREFIX}_FOUND) message( FATAL_ERROR - "The package ${DEPENDENCY} has not been detected correctly.\n" - "Have you called ADD_REQUIRED_DEPENDENCY/ADD_OPTIONAL_DEPENDENCY?") + "The package ${DEPENDENCY} has not been detected correctly.\n" + "Have you called ADD_REQUIRED_DEPENDENCY/ADD_OPTIONAL_DEPENDENCY?" + ) endif() if(NOT (${LPREFIX}_FOUND OR ${LPREFIX}_DEBUG_FOUND)) message(FATAL_ERROR "The package ${DEPENDENCY} has not been found.") endif() set(${PREFIX} ${LPREFIX}) - endmacro(BUILD_PREFIX_FOR_PKG) # .rst: .. ifmode:: import @@ -1100,16 +1206,19 @@ macro(PKG_CONFIG_USE_DEPENDENCY TARGET DEPENDENCY) set(options NO_INCLUDE_SYSTEM) set(oneValueArgs) set(multiValueArgs) - cmake_parse_arguments(PKG_CONFIG_USE_DEPENDENCY "${options}" - "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + cmake_parse_arguments( + PKG_CONFIG_USE_DEPENDENCY + "${options}" + "${oneValueArgs}" + "${multiValueArgs}" + ${ARGN} + ) build_prefix_for_pkg(${DEPENDENCY} PREFIX) pkg_config_use_lcompile_dependency( - ${TARGET} ${PREFIX} ${PKG_CONFIG_USE_DEPENDENCY_NO_INCLUDE_SYSTEM}) + ${TARGET} ${PREFIX} ${PKG_CONFIG_USE_DEPENDENCY_NO_INCLUDE_SYSTEM} + ) pkg_config_use_llink_dependency(${TARGET} ${PREFIX}) -endmacro( - PKG_CONFIG_USE_DEPENDENCY - TARGET - DEPENDENCY) +endmacro(PKG_CONFIG_USE_DEPENDENCY TARGET DEPENDENCY) # .rst: .. ifmode:: import-advanced # @@ -1131,15 +1240,18 @@ macro(PKG_CONFIG_USE_COMPILE_DEPENDENCY TARGET DEPENDENCY) set(options NO_INCLUDE_SYSTEM) set(oneValueArgs) set(multiValueArgs) - cmake_parse_arguments(PKG_CONFIG_USE_DEPENDENCY "${options}" - "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + cmake_parse_arguments( + PKG_CONFIG_USE_DEPENDENCY + "${options}" + "${oneValueArgs}" + "${multiValueArgs}" + ${ARGN} + ) build_prefix_for_pkg(${DEPENDENCY} PREFIX) pkg_config_use_lcompile_dependency( - ${TARGET} ${PREFIX} ${PKG_CONFIG_USE_COMPILE_DEPENDENCY_NO_INCLUDE_SYSTEM}) -endmacro( - PKG_CONFIG_USE_COMPILE_DEPENDENCY - TARGET - DEPENDENCY) + ${TARGET} ${PREFIX} ${PKG_CONFIG_USE_COMPILE_DEPENDENCY_NO_INCLUDE_SYSTEM} + ) +endmacro(PKG_CONFIG_USE_COMPILE_DEPENDENCY TARGET DEPENDENCY) # .rst: .. ifmode:: import-advanced # @@ -1151,10 +1263,7 @@ endmacro( macro(PKG_CONFIG_USE_LINK_DEPENDENCY TARGET DEPENDENCY) build_prefix_for_pkg(${DEPENDENCY} PREFIX) pkg_config_use_llink_dependency(${TARGET} ${PREFIX}) -endmacro( - PKG_CONFIG_USE_LINK_DEPENDENCY - TARGET - DEPENDENCY) +endmacro(PKG_CONFIG_USE_LINK_DEPENDENCY TARGET DEPENDENCY) # .rst: .. ifmode:: import-advanced # @@ -1177,7 +1286,4 @@ macro(PKG_CONFIG_ADD_COMPILE_OPTIONS COMPILE_OPTIONS DEPENDENCY) foreach(FLAG ${${PREFIX}_CFLAGS_OTHER}) list(APPEND COMPILE_OPTIONS "${FLAG}") endforeach() -endmacro( - PKG_CONFIG_ADD_COMPILE_OPTIONS - COMPILE_OPTIONS - DEPENDENCY) +endmacro(PKG_CONFIG_ADD_COMPILE_OPTIONS COMPILE_OPTIONS DEPENDENCY) diff --git a/portability.cmake b/portability.cmake index 78b9c63e3..1cbd70370 100644 --- a/portability.cmake +++ b/portability.cmake @@ -36,8 +36,11 @@ function(CONFIG_FILES) foreach(I RANGE 0 ${ARGC}) set(FILE ${ARGV${I}}) if(FILE) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${FILE}.in - ${CMAKE_CURRENT_BINARY_DIR}/${FILE} @ONLY) + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/${FILE}.in + ${CMAKE_CURRENT_BINARY_DIR}/${FILE} + @ONLY + ) endif(FILE) endforeach(I RANGE 0 ${ARGC}) endfunction(CONFIG_FILES) @@ -53,8 +56,10 @@ function(CONFIG_FILES_CMAKE) foreach(I RANGE 0 ${ARGC}) set(FILE ${ARGV${I}}) if(FILE) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${FILE}.cmake - ${CMAKE_CURRENT_BINARY_DIR}/${FILE}) + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/${FILE}.cmake + ${CMAKE_CURRENT_BINARY_DIR}/${FILE} + ) endif(FILE) endforeach(I RANGE 0 ${ARGC}) endfunction(CONFIG_FILES_CMAKE) @@ -70,8 +75,6 @@ endfunction(CONFIG_FILES_CMAKE) function(NORMALIZE_PATH mypath) if(WIN32) string(REPLACE "\\" "/" ${mypath} "${${mypath}}") - set(${mypath} - ${${mypath}} - PARENT_SCOPE) + set(${mypath} ${${mypath}} PARENT_SCOPE) endif(WIN32) endfunction(NORMALIZE_PATH) diff --git a/post-project.cmake b/post-project.cmake index 0c5b53923..7fb1ed6ed 100644 --- a/post-project.cmake +++ b/post-project.cmake @@ -40,8 +40,13 @@ else(${ARGC}) endif(${ARGC}) option(BUILD_DOCUMENTATION "Build the documentation." ON) -cmake_dependent_option(INSTALL_DOCUMENTATION "Install the documentation." ON - BUILD_DOCUMENTATION OFF) +cmake_dependent_option( + INSTALL_DOCUMENTATION + "Install the documentation." + ON + BUILD_DOCUMENTATION + OFF +) option(INSTALL_GENERATED_HEADERS "Generate and install standard headers" ON) option(INSTALL_PKG_CONFIG_FILE "Generate and install standard .pc file" ON) diff --git a/pthread.cmake b/pthread.cmake index 8546af032..8c2c37799 100644 --- a/pthread.cmake +++ b/pthread.cmake @@ -25,8 +25,12 @@ macro(SEARCH_FOR_PTHREAD) if(CMAKE_USE_PTHREADS_INIT) add_definitions(-pthread) else(CMAKE_USE_PTHREADS_INIT) - message(FATAL_ERROR "Pthread is required on Unix, but " - ${CMAKE_THREAD_LIBS_INIT} " has been detected.") + message( + FATAL_ERROR + "Pthread is required on Unix, but " + ${CMAKE_THREAD_LIBS_INIT} + " has been detected." + ) endif(CMAKE_USE_PTHREADS_INIT) elseif(WIN32) # Nothing to do. @@ -41,5 +45,6 @@ macro(SEARCH_FOR_PTHREAD) CMAKE_USE_SPROC_INIT CMAKE_USE_WIN32_THREADS_INIT CMAKE_USE_PTHREADS_INIT - CMAKE_HP_PTHREADS_INIT) + CMAKE_HP_PTHREADS_INIT + ) endmacro(SEARCH_FOR_PTHREAD) diff --git a/python-helpers.cmake b/python-helpers.cmake index 16c7351aa..a8050e3be 100644 --- a/python-helpers.cmake +++ b/python-helpers.cmake @@ -20,8 +20,10 @@ macro(PYTHON_INSTALL MODULE FILE DEST) python_build("${MODULE}" "${FILE}") - install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/${MODULE}/${FILE}" - DESTINATION "${DEST}/${MODULE}") + install( + FILES "${CMAKE_CURRENT_SOURCE_DIR}/${MODULE}/${FILE}" + DESTINATION "${DEST}/${MODULE}" + ) endmacro() # .rst: .. command:: PYTHON_INSTALL_ON_SITE (MODULE FILE) @@ -39,17 +41,19 @@ endmacro() # function(PYTHON_BUILD_GET_TARGET python_build_target) # Regex from IsValidTargetName in CMake/Source/cmGeneratorExpression.cxx - string(REGEX - REPLACE "[^A-Za-z0-9_.+-]" "_" compile_pyc - "${PROJECT_NAME}_compile_pyc_${CMAKE_CURRENT_SOURCE_DIR}") + string( + REGEX REPLACE + "[^A-Za-z0-9_.+-]" + "_" + compile_pyc + "${PROJECT_NAME}_compile_pyc_${CMAKE_CURRENT_SOURCE_DIR}" + ) if(NOT TARGET ${compile_pyc}) add_custom_target(${compile_pyc} ALL) endif() - set(${python_build_target} - ${compile_pyc} - PARENT_SCOPE) + set(${python_build_target} ${compile_pyc} PARENT_SCOPE) endfunction(PYTHON_BUILD_GET_TARGET NAME) # PYTHON_BUILD(MODULE FILE DEST) @@ -76,7 +80,8 @@ macro(PYTHON_BUILD MODULE FILE) add_custom_command( TARGET ${python_build_target} PRE_BUILD - COMMAND ${CMAKE_COMMAND} -E make_directory "${OUTPUT_FILE_DIR}") + COMMAND ${CMAKE_COMMAND} -E make_directory "${OUTPUT_FILE_DIR}" + ) python_build_file(${INPUT_FILE} ${OUTPUT_FILE}) endmacro() @@ -103,7 +108,8 @@ macro(PYTHON_BUILD_FILE FILE) COMMAND "${PYTHON_EXECUTABLE}" -c "import py_compile; py_compile.compile(\"${FILE}\",\"${OUTPUT_FILE}\")" - VERBATIM) + VERBATIM + ) # Tag pyc file as generated. set_source_files_properties("${OUTPUT_FILE}" PROPERTIES GENERATED TRUE) @@ -112,5 +118,6 @@ macro(PYTHON_BUILD_FILE FILE) set_property( DIRECTORY APPEND - PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${OUTPUT_FILE}") + PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${OUTPUT_FILE}" + ) endmacro() diff --git a/python.cmake b/python.cmake index b4a6e14ed..ea47a90ee 100644 --- a/python.cmake +++ b/python.cmake @@ -59,7 +59,7 @@ macro(FINDPYTHON) if(DEFINED FINDPYTHON_ALREADY_CALLED) message( AUTHOR_WARNING - "Macro FINDPYTHON has already been called. Several call to FINDPYTHON may not find the same Python version (for a yet unknown reason)." + "Macro FINDPYTHON has already been called. Several call to FINDPYTHON may not find the same Python version (for a yet unknown reason)." ) endif() set(FINDPYTHON_ALREADY_CALLED TRUE) @@ -79,7 +79,7 @@ macro(FINDPYTHON) if(NOT ${_index} EQUAL -1) message( STATUS - "For CMake < 3.18, Development.Module is not available. Falling back to Development" + "For CMake < 3.18, Development.Module is not available. Falling back to Development" ) list(REMOVE_ITEM PYTHON_COMPONENTS Development.Module) set(PYTHON_COMPONENTS ${PYTHON_COMPONENTS} Development) @@ -88,7 +88,7 @@ macro(FINDPYTHON) if(SEARCH_FOR_NUMPY) message( STATUS - "For CMake < 3.14, NumPy is not available. Falling back to custom FIND_NUMPY()" + "For CMake < 3.14, NumPy is not available. Falling back to custom FIND_NUMPY()" ) list(REMOVE_ITEM PYTHON_COMPONENTS NumPy) endif() @@ -96,12 +96,12 @@ macro(FINDPYTHON) endif() if(NOT CMAKE_VERSION VERSION_LESS "3.12") - - if(DEFINED PYTHON_EXECUTABLE - OR DEFINED Python_EXECUTABLE - OR DEFINED Python2_EXECUTABLE - OR DEFINED Python3_EXECUTABLE) - + if( + DEFINED PYTHON_EXECUTABLE + OR DEFINED Python_EXECUTABLE + OR DEFINED Python2_EXECUTABLE + OR DEFINED Python3_EXECUTABLE + ) if(NOT DEFINED PYTHON_EXECUTABLE) if(DEFINED Python_EXECUTABLE) set(PYTHON_EXECUTABLE ${Python_EXECUTABLE}) @@ -124,7 +124,8 @@ macro(FINDPYTHON) if(NOT EXISTS ${PYTHON_EXECUTABLE}) message( FATAL_ERROR - "${PYTHON_EXECUTABLE} is not a valid path to the Python executable") + "${PYTHON_EXECUTABLE} is not a valid path to the Python executable" + ) endif() execute_process( COMMAND ${PYTHON_EXECUTABLE} --version @@ -132,30 +133,41 @@ macro(FINDPYTHON) RESULT_VARIABLE _PYTHON_VERSION_RESULT_VARIABLE OUTPUT_VARIABLE _PYTHON_VERSION_OUTPUT ERROR_VARIABLE _PYTHON_VERSION_OUTPUT - OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_STRIP_TRAILING_WHITESPACE) + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_STRIP_TRAILING_WHITESPACE + ) if(NOT "${_PYTHON_VERSION_RESULT_VARIABLE}" STREQUAL "0") message(FATAL_ERROR "${PYTHON_EXECUTABLE} --version did not succeed.") endif() - string(REGEX REPLACE "Python " "" _PYTHON_VERSION - ${_PYTHON_VERSION_OUTPUT}) + string( + REGEX REPLACE + "Python " + "" + _PYTHON_VERSION + ${_PYTHON_VERSION_OUTPUT} + ) string(REGEX REPLACE "\\." ";" _PYTHON_VERSION ${_PYTHON_VERSION}) list(GET _PYTHON_VERSION 0 _PYTHON_VERSION_MAJOR) # Provide some hints according to the current PYTHON_EXECUTABLE if(NOT DEFINED PYTHON_INCLUDE_DIR) if(_PYTHON_VERSION_MAJOR EQUAL "2") - set(_PYTHON_INCLUDE_DIR_CMD - "import distutils.sysconfig as sysconfig; print(sysconfig.get_python_inc())" + set( + _PYTHON_INCLUDE_DIR_CMD + "import distutils.sysconfig as sysconfig; print(sysconfig.get_python_inc())" ) else() - set(_PYTHON_INCLUDE_DIR_CMD - "import sysconfig; print(sysconfig.get_path('include'))") + set( + _PYTHON_INCLUDE_DIR_CMD + "import sysconfig; print(sysconfig.get_path('include'))" + ) endif() execute_process( COMMAND "${PYTHON_EXECUTABLE}" "-c" "${_PYTHON_INCLUDE_DIR_CMD}" OUTPUT_VARIABLE PYTHON_INCLUDE_DIR - ERROR_QUIET) + ERROR_QUIET + ) string(STRIP "${PYTHON_INCLUDE_DIR}" PYTHON_INCLUDE_DIR) file(TO_CMAKE_PATH "${PYTHON_INCLUDE_DIR}" PYTHON_INCLUDE_DIR) endif() @@ -170,9 +182,11 @@ macro(FINDPYTHON) set(Python_NumPy_INCLUDE_DIR ${NUMPY_INCLUDE_DIRS}) endif() - find_package("Python${_PYTHON_VERSION_MAJOR}" REQUIRED - COMPONENTS ${PYTHON_COMPONENTS}) - + find_package( + "Python${_PYTHON_VERSION_MAJOR}" + REQUIRED + COMPONENTS ${PYTHON_COMPONENTS} + ) else() # No hint was provided. We can then check for first Python 2, then Python # 3 @@ -209,14 +223,14 @@ macro(FINDPYTHON) endif() if(SEARCH_FOR_NUMPY) - set(NUMPY_INCLUDE_DIRS - "${Python${_PYTHON_VERSION_MAJOR}_NumPy_INCLUDE_DIRS}") + set( + NUMPY_INCLUDE_DIRS + "${Python${_PYTHON_VERSION_MAJOR}_NumPy_INCLUDE_DIRS}" + ) string(REPLACE "\\" "/" NUMPY_INCLUDE_DIRS "${NUMPY_INCLUDE_DIRS}") file(TO_CMAKE_PATH "${NUMPY_INCLUDE_DIRS}" NUMPY_INCLUDE_DIRS) endif() - else() - find_package(PythonInterp ${ARGN}) if(NOT ${PYTHONINTERP_FOUND} STREQUAL TRUE) message(FATAL_ERROR "Python executable has not been found.") @@ -229,21 +243,24 @@ macro(FINDPYTHON) # defined if(NOT DEFINED PYTHON_INCLUDE_DIR) if(PYTHON_VERSION_MAJOR EQUAL "2") - set(_PYTHON_INCLUDE_DIR_CMD - "import distutils.sysconfig as sysconfig; print(sysconfig.get_python_inc())" + set( + _PYTHON_INCLUDE_DIR_CMD + "import distutils.sysconfig as sysconfig; print(sysconfig.get_python_inc())" ) else() - set(_PYTHON_INCLUDE_DIR_CMD - "import sysconfig; print(sysconfig.get_path('include'))") + set( + _PYTHON_INCLUDE_DIR_CMD + "import sysconfig; print(sysconfig.get_path('include'))" + ) endif() execute_process( COMMAND "${PYTHON_EXECUTABLE}" "-c" "${_PYTHON_INCLUDE_DIR_CMD}" OUTPUT_VARIABLE PYTHON_INCLUDE_DIR - ERROR_QUIET) + ERROR_QUIET + ) string(STRIP "${PYTHON_INCLUDE_DIR}" PYTHON_INCLUDE_DIR) endif() set(PYTHON_INCLUDE_DIRS ${PYTHON_INCLUDE_DIR}) - endif() # Inform PythonLibs of the required version of PythonInterp @@ -259,14 +276,15 @@ macro(FINDPYTHON) list(GET _PYTHONLIBS_VERSION 0 PYTHONLIBS_VERSION_MAJOR) list(GET _PYTHONLIBS_VERSION 1 PYTHONLIBS_VERSION_MINOR) - if(NOT ${PYTHON_VERSION_MAJOR} EQUAL ${PYTHONLIBS_VERSION_MAJOR} - OR NOT ${PYTHON_VERSION_MINOR} EQUAL ${PYTHONLIBS_VERSION_MINOR}) + if( + NOT ${PYTHON_VERSION_MAJOR} EQUAL ${PYTHONLIBS_VERSION_MAJOR} + OR NOT ${PYTHON_VERSION_MINOR} EQUAL ${PYTHONLIBS_VERSION_MINOR} + ) message( FATAL_ERROR - "Python interpreter and libraries are in different version: ${PYTHON_VERSION_STRING} vs ${PYTHONLIBS_VERSION_STRING}" + "Python interpreter and libraries are in different version: ${PYTHON_VERSION_STRING} vs ${PYTHONLIBS_VERSION_STRING}" ) endif() - endif() # Find PYTHON_LIBRARY_DIRS @@ -284,17 +302,20 @@ macro(FINDPYTHON) option(PYTHON_STANDARD_LAYOUT "Enable standard Python package layout" OFF) if(PYTHON_STANDARD_LAYOUT) - set(_PYTHON_SITELIB_CMD - "import sys, os; print(os.sep.join(['lib', 'python' + '.'.join(sys.version.split('.')[:2]), 'site-packages']))" + set( + _PYTHON_SITELIB_CMD + "import sys, os; print(os.sep.join(['lib', 'python' + '.'.join(sys.version.split('.')[:2]), 'site-packages']))" ) else() if(PYTHON_VERSION_MAJOR EQUAL "2") - set(_PYTHON_SITELIB_CMD - "from distutils import sysconfig; print(sysconfig.get_python_lib(prefix='', plat_specific=False))" + set( + _PYTHON_SITELIB_CMD + "from distutils import sysconfig; print(sysconfig.get_python_lib(prefix='', plat_specific=False))" ) else() - set(_PYTHON_SITELIB_CMD - "import sysconfig; from pathlib import Path; print(Path(sysconfig.get_path('purelib')).relative_to(sysconfig.get_path('data')))" + set( + _PYTHON_SITELIB_CMD + "import sysconfig; from pathlib import Path; print(Path(sysconfig.get_path('purelib')).relative_to(sysconfig.get_path('data')))" ) endif() endif() @@ -302,20 +323,31 @@ macro(FINDPYTHON) execute_process( COMMAND "${PYTHON_EXECUTABLE}" "-c" "${_PYTHON_SITELIB_CMD}" OUTPUT_VARIABLE PYTHON_SITELIB - OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET) + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET + ) # Keep compatility with former jrl-cmake-modules versions if(PYTHON_DEB_LAYOUT) - string(REPLACE "site-packages" "dist-packages" PYTHON_SITELIB - "${PYTHON_SITELIB}") + string( + REPLACE + "site-packages" + "dist-packages" + PYTHON_SITELIB + "${PYTHON_SITELIB}" + ) endif() # If PYTHON_PACKAGES_DIR is defined, then force the Python packages # directory name if(PYTHON_PACKAGES_DIR) - string(REGEX - REPLACE "(site-packages|dist-packages)" "${PYTHON_PACKAGES_DIR}" - PYTHON_SITELIB "${PYTHON_SITELIB}") + string( + REGEX REPLACE + "(site-packages|dist-packages)" + "${PYTHON_PACKAGES_DIR}" + PYTHON_SITELIB + "${PYTHON_SITELIB}" + ) endif() endif() @@ -330,7 +362,8 @@ macro(FINDPYTHON) COMMAND "${PYTHON_EXECUTABLE}" "-c" "from sysconfig import get_config_var; print('.' + get_config_var('SOABI'))" - OUTPUT_VARIABLE PYTHON_SOABI) + OUTPUT_VARIABLE PYTHON_SOABI + ) string(STRIP ${PYTHON_SOABI} PYTHON_SOABI) endif() @@ -341,7 +374,8 @@ macro(FINDPYTHON) COMMAND "${PYTHON_EXECUTABLE}" "-c" "from sysconfig import get_config_var; print(get_config_var('EXT_SUFFIX'))" - OUTPUT_VARIABLE PYTHON_EXT_SUFFIX) + OUTPUT_VARIABLE PYTHON_EXT_SUFFIX + ) string(STRIP ${PYTHON_EXT_SUFFIX} PYTHON_EXT_SUFFIX) endif() if("${PYTHON_EXT_SUFFIX}" STREQUAL "") @@ -356,19 +390,23 @@ macro(FINDPYTHON) install_jrl_cmakemodules_file("python.cmake") install_jrl_cmakemodules_file("python-helpers.cmake") string( - CONCAT PYTHON_EXPORT_DEPENDENCY_MACROS - "list(APPEND PYTHON_COMPONENTS ${PYTHON_COMPONENTS})\n" - "list(REMOVE_DUPLICATES PYTHON_COMPONENTS)\n" - "if(NOT FINDPYTHON_ALREADY_CALLED)\n" - "FINDPYTHON()\n" - "endif()\n") + CONCAT + PYTHON_EXPORT_DEPENDENCY_MACROS + "list(APPEND PYTHON_COMPONENTS ${PYTHON_COMPONENTS})\n" + "list(REMOVE_DUPLICATES PYTHON_COMPONENTS)\n" + "if(NOT FINDPYTHON_ALREADY_CALLED)\n" + "FINDPYTHON()\n" + "endif()\n" + ) endif() if(SEARCH_FOR_NUMPY) find_numpy() if(PYTHON_EXPORT_DEPENDENCY) - set(PYTHON_EXPORT_DEPENDENCY_MACROS - "set(SEARCH_FOR_NUMPY TRUE)\n${PYTHON_EXPORT_DEPENDENCY_MACROS}") + set( + PYTHON_EXPORT_DEPENDENCY_MACROS + "set(SEARCH_FOR_NUMPY TRUE)\n${PYTHON_EXPORT_DEPENDENCY_MACROS}" + ) endif() endif() @@ -387,8 +425,8 @@ macro(FINDPYTHON) PYTHONLIBS_VERSION_STRING PYTHON_EXECUTABLE PYTHON_SOABI - PYTHON_EXT_SUFFIX) - + PYTHON_EXT_SUFFIX + ) endmacro(FINDPYTHON) # .rst: .. command:: DYNAMIC_GRAPH_PYTHON_MODULE ( SUBMODULENAME LIBRARYNAME @@ -415,11 +453,15 @@ endmacro(FINDPYTHON) # the name referencing the type in the factory. # macro(DYNAMIC_GRAPH_PYTHON_MODULE SUBMODULENAME LIBRARYNAME TARGETNAME) - set(options DONT_INSTALL_INIT_PY) set(oneValueArgs SOURCE_PYTHON_MODULE MODULE_HEADER) - cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" - ${ARGN}) + cmake_parse_arguments( + ARG + "${options}" + "${oneValueArgs}" + "${multiValueArgs}" + ${ARGN} + ) # By default the __init__.py file is installed. if(NOT DEFINED ARG_SOURCE_PYTHON_MODULE) @@ -427,9 +469,11 @@ macro(DYNAMIC_GRAPH_PYTHON_MODULE SUBMODULENAME LIBRARYNAME TARGETNAME) configure_file( ${PROJECT_JRL_CMAKE_MODULE_DIR}/dynamic_graph/python-module-py.cc.in ${PROJECT_BINARY_DIR}/src/dynamic_graph/${SUBMODULENAME}/python-module-py.cc - @ONLY) - set(ARG_SOURCE_PYTHON_MODULE - "${PROJECT_BINARY_DIR}/src/dynamic_graph/${SUBMODULENAME}/python-module-py.cc" + @ONLY + ) + set( + ARG_SOURCE_PYTHON_MODULE + "${PROJECT_BINARY_DIR}/src/dynamic_graph/${SUBMODULENAME}/python-module-py.cc" ) endif() @@ -444,8 +488,13 @@ macro(DYNAMIC_GRAPH_PYTHON_MODULE SUBMODULENAME LIBRARYNAME TARGETNAME) file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/src/dynamic_graph/${SUBMODULENAME}) set(PYTHON_INSTALL_DIR "${PYTHON_SITELIB}/dynamic_graph/${SUBMODULENAME}") - string(REGEX REPLACE "[^/]+" ".." PYTHON_INSTALL_DIR_REVERSE - ${PYTHON_INSTALL_DIR}) + string( + REGEX REPLACE + "[^/]+" + ".." + PYTHON_INSTALL_DIR_REVERSE + ${PYTHON_INSTALL_DIR} + ) set_target_properties( ${PYTHON_MODULE} @@ -453,24 +502,31 @@ macro(DYNAMIC_GRAPH_PYTHON_MODULE SUBMODULENAME LIBRARYNAME TARGETNAME) PREFIX "" OUTPUT_NAME dynamic_graph/${SUBMODULENAME}/wrap BUILD_RPATH - "${DYNAMIC_GRAPH_PLUGINDIR}:\$ORIGIN/${PYTHON_INSTALL_DIR_REVERSE}/${DYNAMIC_GRAPH_PLUGINDIR}" + "${DYNAMIC_GRAPH_PLUGINDIR}:\$ORIGIN/${PYTHON_INSTALL_DIR_REVERSE}/${DYNAMIC_GRAPH_PLUGINDIR}" ) if(UNIX AND NOT APPLE) target_link_libraries(${PYTHON_MODULE} PUBLIC "-Wl,--no-as-needed") endif() - target_link_libraries(${PYTHON_MODULE} PUBLIC ${LIBRARYNAME} - dynamic-graph::dynamic-graph) + target_link_libraries( + ${PYTHON_MODULE} + PUBLIC ${LIBRARYNAME} dynamic-graph::dynamic-graph + ) target_link_boost_python(${PYTHON_MODULE} PUBLIC) if(PROJECT_NAME STREQUAL "dynamic-graph-python") target_link_libraries(${PYTHON_MODULE} PUBLIC dynamic-graph-python) else() - target_link_libraries(${PYTHON_MODULE} - PUBLIC dynamic-graph-python::dynamic-graph-python) + target_link_libraries( + ${PYTHON_MODULE} + PUBLIC dynamic-graph-python::dynamic-graph-python + ) endif() - target_include_directories(${PYTHON_MODULE} SYSTEM - PRIVATE ${PYTHON_INCLUDE_DIRS}) + target_include_directories( + ${PYTHON_MODULE} + SYSTEM + PRIVATE ${PYTHON_INCLUDE_DIRS} + ) # # Installation @@ -485,17 +541,16 @@ macro(DYNAMIC_GRAPH_PYTHON_MODULE SUBMODULENAME LIBRARYNAME TARGETNAME) # Install if not DONT_INSTALL_INIT_PY if(NOT DONT_INSTALL_INIT_PY) - configure_file( ${PROJECT_JRL_CMAKE_MODULE_DIR}/dynamic_graph/submodule/__init__.py.cmake - ${PROJECT_BINARY_DIR}/src/dynamic_graph/${SUBMODULENAME}/__init__.py) + ${PROJECT_BINARY_DIR}/src/dynamic_graph/${SUBMODULENAME}/__init__.py + ) install( FILES ${PROJECT_BINARY_DIR}/src/dynamic_graph/${SUBMODULENAME}/__init__.py - DESTINATION ${PYTHON_INSTALL_DIR}) - + DESTINATION ${PYTHON_INSTALL_DIR} + ) endif() - endmacro(DYNAMIC_GRAPH_PYTHON_MODULE SUBMODULENAME) # .rst: .. command:: FIND_NUMPY() @@ -510,26 +565,30 @@ macro(FIND_NUMPY) execute_process( COMMAND "${PYTHON_EXECUTABLE}" "-c" "import numpy; print (True)" OUTPUT_VARIABLE IS_NUMPY - ERROR_QUIET) + ERROR_QUIET + ) if(NOT IS_NUMPY) message(FATAL_ERROR "Failed to detect numpy") else() if(NOT NUMPY_INCLUDE_DIRS) execute_process( - COMMAND "${PYTHON_EXECUTABLE}" "-c" - "import numpy; print (numpy.get_include())" + COMMAND + "${PYTHON_EXECUTABLE}" "-c" + "import numpy; print (numpy.get_include())" OUTPUT_VARIABLE NUMPY_INCLUDE_DIRS - ERROR_QUIET) + ERROR_QUIET + ) string(REGEX REPLACE "\n$" "" NUMPY_INCLUDE_DIRS "${NUMPY_INCLUDE_DIRS}") file(TO_CMAKE_PATH "${NUMPY_INCLUDE_DIRS}" NUMPY_INCLUDE_DIRS) endif() message(STATUS " NUMPY_INCLUDE_DIRS=${NUMPY_INCLUDE_DIRS}") # Retrive NUMPY_VERSION execute_process( - COMMAND "${PYTHON_EXECUTABLE}" "-c" - "import numpy; print (numpy.__version__)" + COMMAND + "${PYTHON_EXECUTABLE}" "-c" "import numpy; print (numpy.__version__)" OUTPUT_VARIABLE NUMPY_VERSION - ERROR_QUIET) + ERROR_QUIET + ) string(REGEX REPLACE "\n$" "" NUMPY_VERSION "${NUMPY_VERSION}") message(STATUS " NUMPY_VERSION=${NUMPY_VERSION}") endif() @@ -544,17 +603,19 @@ macro(FIND_SCIPY) execute_process( COMMAND "${PYTHON_EXECUTABLE}" "-c" "import scipy; print (True)" OUTPUT_VARIABLE IS_SCIPY - ERROR_QUIET) + ERROR_QUIET + ) if(NOT IS_SCIPY) message(FATAL_ERROR "Failed to detect scipy") else() # Retrive SCIPY_VERSION execute_process( - COMMAND "${PYTHON_EXECUTABLE}" "-c" - "import scipy; print (scipy.__version__)" + COMMAND + "${PYTHON_EXECUTABLE}" "-c" "import scipy; print (scipy.__version__)" OUTPUT_VARIABLE SCIPY_VERSION - ERROR_QUIET) + ERROR_QUIET + ) string(REGEX REPLACE "\n$" "" SCIPY_VERSION "${SCIPY_VERSION}") message(STATUS " SCIPY_VERSION=${SCIPY_VERSION}") endif() diff --git a/qhull.cmake b/qhull.cmake index 4ae857fc2..d92fcafa6 100644 --- a/qhull.cmake +++ b/qhull.cmake @@ -14,21 +14,21 @@ # This macro adds detected flags to the pkg-config file automatically. # macro(SEARCH_FOR_QHULL) - set(QHULL_MAJOR_VERSION 6) find_file( QHULL_HEADER NAMES libqhull/libqhull.h qhull.h HINTS "${QHULL_ROOT}" "$ENV{QHULL_ROOT}" "${QHULL_INCLUDE_DIR}" - PATHS "$ENV{PROGRAMFILES}/QHull" "$ENV{PROGRAMW6432}/QHull" - "$ENV{PROGRAMFILES}/qhull 6.2.0.1373" - "$ENV{PROGRAMW6432}/qhull 6.2.0.1373" - PATH_SUFFIXES qhull src/libqhull libqhull include) + PATHS + "$ENV{PROGRAMFILES}/QHull" + "$ENV{PROGRAMW6432}/QHull" + "$ENV{PROGRAMFILES}/qhull 6.2.0.1373" + "$ENV{PROGRAMW6432}/qhull 6.2.0.1373" + PATH_SUFFIXES qhull src/libqhull libqhull include + ) - set(QHULL_HEADER - "${QHULL_HEADER}" - CACHE INTERNAL "QHull header" FORCE) + set(QHULL_HEADER "${QHULL_HEADER}" CACHE INTERNAL "QHull header" FORCE) if(QHULL_HEADER) get_filename_component(qhull_header ${QHULL_HEADER} NAME_WE) @@ -44,9 +44,13 @@ macro(SEARCH_FOR_QHULL) set(QHULL_INCLUDE_DIR "QHULL_INCLUDE_DIR-NOTFOUND") endif(QHULL_HEADER) - set(QHULL_INCLUDE_DIR - "${QHULL_INCLUDE_DIR}" - CACHE PATH "QHull include dir." FORCE) + set( + QHULL_INCLUDE_DIR + "${QHULL_INCLUDE_DIR}" + CACHE PATH + "QHull include dir." + FORCE + ) # Prefer static libraries in Windows over shared ones if(WIN32) @@ -54,39 +58,55 @@ macro(SEARCH_FOR_QHULL) QHULL_LIBRARY NAMES qhullstatic qhull qhull${QHULL_MAJOR_VERSION} HINTS "${QHULL_ROOT}" "$ENV{QHULL_ROOT}" - PATHS "$ENV{PROGRAMFILES}/QHull" "$ENV{PROGRAMW6432}/QHull" - "$ENV{PROGRAMFILES}/qhull 6.2.0.1373" - "$ENV{PROGRAMW6432}/qhull 6.2.0.1373" - PATH_SUFFIXES project build bin lib) + PATHS + "$ENV{PROGRAMFILES}/QHull" + "$ENV{PROGRAMW6432}/QHull" + "$ENV{PROGRAMFILES}/qhull 6.2.0.1373" + "$ENV{PROGRAMW6432}/qhull 6.2.0.1373" + PATH_SUFFIXES project build bin lib + ) find_library( QHULL_LIBRARY_DEBUG - NAMES qhullstatic_d qhull_d qhull_d${QHULL_MAJOR_VERSION} qhull - qhull${QHULL_MAJOR_VERSION} + NAMES + qhullstatic_d + qhull_d + qhull_d${QHULL_MAJOR_VERSION} + qhull + qhull${QHULL_MAJOR_VERSION} HINTS "${QHULL_ROOT}" "$ENV{QHULL_ROOT}" - PATHS "$ENV{PROGRAMFILES}/QHull" "$ENV{PROGRAMW6432}/QHull" - "$ENV{PROGRAMFILES}/qhull 6.2.0.1373" - "$ENV{PROGRAMW6432}/qhull 6.2.0.1373" - PATH_SUFFIXES project build bin lib) + PATHS + "$ENV{PROGRAMFILES}/QHull" + "$ENV{PROGRAMW6432}/QHull" + "$ENV{PROGRAMFILES}/qhull 6.2.0.1373" + "$ENV{PROGRAMW6432}/qhull 6.2.0.1373" + PATH_SUFFIXES project build bin lib + ) else(WIN32) find_library( QHULL_LIBRARY NAMES qhull qhull${QHULL_MAJOR_VERSION} HINTS "${QHULL_ROOT}" "$ENV{QHULL_ROOT}" - PATH_SUFFIXES project build bin lib) + PATH_SUFFIXES project build bin lib + ) find_library( QHULL_LIBRARY_DEBUG - NAMES qhull_d qhull_d${QHULL_MAJOR_VERSION} qhull - qhull${QHULL_MAJOR_VERSION} + NAMES + qhull_d + qhull_d${QHULL_MAJOR_VERSION} + qhull + qhull${QHULL_MAJOR_VERSION} HINTS "${QHULL_ROOT}" "$ENV{QHULL_ROOT}" - PATH_SUFFIXES project build bin lib) + PATH_SUFFIXES project build bin lib + ) find_library( QHULL_CPP_LIBRARY NAMES qhullcpp HINTS "${QHULL_ROOT}" "$ENV{QHULL_ROOT}" - PATH_SUFFIXES project build bin lib) + PATH_SUFFIXES project build bin lib + ) endif(WIN32) if(NOT QHULL_LIBRARY_DEBUG) @@ -102,11 +122,19 @@ macro(SEARCH_FOR_QHULL) endif(QHULL_CPP_LIBRARY) include(FindPackageHandleStandardArgs) - find_package_handle_standard_args(Qhull DEFAULT_MSG QHULL_LIBRARY - QHULL_INCLUDE_DIR) - - mark_as_advanced(QHULL_LIBRARY QHULL_LIBRARY_DEBUG QHULL_CPP_LIBRARY - QHULL_INCLUDE_DIR) + find_package_handle_standard_args( + Qhull + DEFAULT_MSG + QHULL_LIBRARY + QHULL_INCLUDE_DIR + ) + + mark_as_advanced( + QHULL_LIBRARY + QHULL_LIBRARY_DEBUG + QHULL_CPP_LIBRARY + QHULL_INCLUDE_DIR + ) if(QHULL_FOUND) set(HAVE_QHULL ON) diff --git a/relpath.cmake b/relpath.cmake index eefc7c3ee..2146dc535 100644 --- a/relpath.cmake +++ b/relpath.cmake @@ -39,8 +39,12 @@ macro(GET_RELATIVE_RPATH TARGET_INSTALL_DIR VARIABLE) endif() rel_install_path("${TARGET_INSTALL_DIR}" _TGT_INV_REL) if(IS_ABSOLUTE ${CMAKE_INSTALL_LIBDIR}) - file(RELATIVE_PATH _LIB_REL "${CMAKE_INSTALL_PREFIX}" - ${CMAKE_INSTALL_LIBDIR}) + file( + RELATIVE_PATH + _LIB_REL + "${CMAKE_INSTALL_PREFIX}" + ${CMAKE_INSTALL_LIBDIR} + ) else() set(_LIB_REL ${CMAKE_INSTALL_LIBDIR}) endif() diff --git a/ros.cmake b/ros.cmake index c8555fc97..437c436e0 100644 --- a/ros.cmake +++ b/ros.cmake @@ -51,7 +51,8 @@ macro(ADD_ROSPACK_DEPENDENCY PKG_ROS) execute_process( COMMAND "${ROSPACK}" find "${PKG}" OUTPUT_VARIABLE "${PKG}_ROS_PREFIX" - ERROR_QUIET) + ERROR_QUIET + ) if(NOT ${PKG}_ROS_PREFIX) message(FATAL_ERROR "Failed to detect ${PKG}.") endif() @@ -60,40 +61,53 @@ macro(ADD_ROSPACK_DEPENDENCY PKG_ROS) find_program(ROSVERSION rosversion) if(NOT ROSVERSION) message( - FATAL_ERROR "failed to find the rosversion binary. Is ROS installed?") + FATAL_ERROR + "failed to find the rosversion binary. Is ROS installed?" + ) endif() execute_process( COMMAND "${ROSVERSION}" "${PKG}" OUTPUT_VARIABLE ${PKG}_ROSVERSION_TMP - ERROR_QUIET) + ERROR_QUIET + ) string(REGEX REPLACE "\n" "" ${PKG}_ROSVERSION ${${PKG}_ROSVERSION_TMP}) # check whether the version satisfies the constraint if(NOT "${SIGN}" STREQUAL "") set(RESULT FALSE) - if(("${${PKG}_ROSVERSION}" VERSION_LESS "${PKG_VERSION}") - AND ((${SIGN} STREQUAL "<=") OR (${SIGN} STREQUAL "<"))) + if( + ("${${PKG}_ROSVERSION}" VERSION_LESS "${PKG_VERSION}") + AND ((${SIGN} STREQUAL "<=") OR (${SIGN} STREQUAL "<")) + ) set(RESULT TRUE) endif() - if(("${${PKG}_ROSVERSION}" VERSION_EQUAL "${PKG_VERSION}") - AND ((${SIGN} STREQUAL ">=") - OR (${SIGN} STREQUAL "=") - OR (${SIGN} STREQUAL "<="))) + if( + ("${${PKG}_ROSVERSION}" VERSION_EQUAL "${PKG_VERSION}") + AND + ( + (${SIGN} STREQUAL ">=") + OR (${SIGN} STREQUAL "=") + OR (${SIGN} STREQUAL "<=") + ) + ) set(RESULT TRUE) endif() - if(("${${PKG}_ROSVERSION}" VERSION_GREATER "${PKG_VERSION}") - AND (("${SIGN}" STREQUAL ">=") OR ("${SIGN}" STREQUAL ">"))) + if( + ("${${PKG}_ROSVERSION}" VERSION_GREATER "${PKG_VERSION}") + AND (("${SIGN}" STREQUAL ">=") OR ("${SIGN}" STREQUAL ">")) + ) set(RESULT TRUE) endif() if(NOT RESULT) message( FATAL_ERROR - "The package ${PKG} does not have the correct version." - " Found: ${${PKG}_ROSVERSION}, desired: ${SIGN} ${PKG_VERSION}") + "The package ${PKG} does not have the correct version." + " Found: ${${PKG}_ROSVERSION}, desired: ${SIGN} ${PKG_VERSION}" + ) endif() endif(NOT "${SIGN}" STREQUAL "") @@ -104,11 +118,13 @@ macro(ADD_ROSPACK_DEPENDENCY PKG_ROS) execute_process( COMMAND "${ROSPACK}" export "--lang=cpp" "--attrib=cflags" "${PKG}" OUTPUT_VARIABLE "${PREFIX}_CFLAGS" - ERROR_QUIET) + ERROR_QUIET + ) execute_process( COMMAND "${ROSPACK}" export "--lang=cpp" "--attrib=lflags" "${PKG}" OUTPUT_VARIABLE "${PREFIX}_LIBS" - ERROR_QUIET) + ERROR_QUIET + ) string(REPLACE "\n" "" ${PREFIX}_CFLAGS "${${PREFIX}_CFLAGS}") string(REPLACE "\n" "" ${PREFIX}_LIBS "${${PREFIX}_LIBS}") string(REPLACE "\n" "" ${PKG}_ROS_PREFIX "${${PKG}_ROS_PREFIX}") @@ -151,8 +167,10 @@ macro(ROSPACK_USE_DEPENDENCY TARGET PKG) set(LDFLAGS "${LDFLAGS} ${${PREFIX}_LIBS}") # Update the flags. - set_target_properties("${TARGET}" PROPERTIES COMPILE_FLAGS "${CFLAGS}" - LINK_FLAGS "${LDFLAGS}") + set_target_properties( + "${TARGET}" + PROPERTIES COMPILE_FLAGS "${CFLAGS}" LINK_FLAGS "${LDFLAGS}" + ) # Correct the potential link issue due to the order of link flags. (appears # e.g. on ubuntu 12.04). Note that this issue is the same as the one in diff --git a/ros2.cmake b/ros2.cmake index ed04839ff..dbeb359a7 100644 --- a/ros2.cmake +++ b/ros2.cmake @@ -23,25 +23,32 @@ macro(_install_project_ros2_ament_files) file( WRITE ${CMAKE_CURRENT_BINARY_DIR}/share/ament_index/resource_index/packages/${PROJECT_NAME} - "") + "" + ) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/share/ament_index/resource_index/packages/${PROJECT_NAME} - DESTINATION share/ament_index/resource_index/packages) + DESTINATION share/ament_index/resource_index/packages + ) file( WRITE ${CMAKE_CURRENT_BINARY_DIR}/share/${PROJECT_NAME}/hook/ament_prefix_path.dsv - "prepend-non-duplicate;AMENT_PREFIX_PATH;") + "prepend-non-duplicate;AMENT_PREFIX_PATH;" + ) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/share/${PROJECT_NAME}/hook/ament_prefix_path.dsv - DESTINATION share/${PROJECT_NAME}/hook) - file(WRITE - ${CMAKE_CURRENT_BINARY_DIR}/share/${PROJECT_NAME}/hook/python_path.dsv - "prepend-non-duplicate;PYTHONPATH;${PYTHON_SITELIB}") + DESTINATION share/${PROJECT_NAME}/hook + ) + file( + WRITE + ${CMAKE_CURRENT_BINARY_DIR}/share/${PROJECT_NAME}/hook/python_path.dsv + "prepend-non-duplicate;PYTHONPATH;${PYTHON_SITELIB}" + ) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/share/${PROJECT_NAME}/hook/python_path.dsv - DESTINATION share/${PROJECT_NAME}/hook) + DESTINATION share/${PROJECT_NAME}/hook + ) endif(BUILDING_ROS2_PACKAGE) endmacro(_install_project_ros2_ament_files) diff --git a/sdformat.cmake b/sdformat.cmake index 15402e224..3e8c4a702 100644 --- a/sdformat.cmake +++ b/sdformat.cmake @@ -11,7 +11,15 @@ # FATAL_ERROR is generated. # macro(SEARCH_FOR_SDFORMAT) - set(SDF_VERSIONS "14" "13" "12" "11" "10" "9") + set( + SDF_VERSIONS + "14" + "13" + "12" + "11" + "10" + "9" + ) list(APPEND SDF_VERSIONS "") set(P_REQUIRED False) set(variadic_args ${ARGN}) @@ -23,7 +31,7 @@ macro(SEARCH_FOR_SDFORMAT) else() message( STATUS - "Got an unknown optional arg: ${optional_arg}. Only REQUIRED is recognized." + "Got an unknown optional arg: ${optional_arg}. Only REQUIRED is recognized." ) endif() endif() @@ -40,7 +48,8 @@ macro(SEARCH_FOR_SDFORMAT) if(P_REQUIRED) message( FATAL_ERROR - "SDFormat required but not found. Accepted versions: ${SDF_VERSIONS}") + "SDFormat required but not found. Accepted versions: ${SDF_VERSIONS}" + ) else() message(STATUS "SDFormat not found. Accepted versions: ${SDF_VERSIONS}") endif() diff --git a/shared-library.cmake b/shared-library.cmake index 8cf31e02c..eee4fbace 100644 --- a/shared-library.cmake +++ b/shared-library.cmake @@ -34,9 +34,14 @@ elseif(UNIX) execute_process( COMMAND ${CMAKE_LINKER} -v OUTPUT_VARIABLE LD_VERSION_STR - ERROR_VARIABLE LD_VERSION_STR) - string(REGEX MATCH "([0-9]+\\.[0-9]+(\\.[0-9]+)?)" LD_VERSION - ${LD_VERSION_STR}) + ERROR_VARIABLE LD_VERSION_STR + ) + string( + REGEX MATCH + "([0-9]+\\.[0-9]+(\\.[0-9]+)?)" + LD_VERSION + ${LD_VERSION_STR} + ) if(${LD_VERSION} VERSION_LESS "2.24.90") set(LIBINCL_ABSKW "-l:") else() diff --git a/sphinx.cmake b/sphinx.cmake index 52337b171..c80f0c7d0 100644 --- a/sphinx.cmake +++ b/sphinx.cmake @@ -30,18 +30,24 @@ macro(SPHINX_SETUP) endif(MSVC) find_program( - SPHINX_BUILD sphinx-build + SPHINX_BUILD + sphinx-build DOC "Sphinx documentation generator tool" - PATHS "${SPHINX_BUILD_PATH}") + PATHS "${SPHINX_BUILD_PATH}" + ) if(NOT SPHINX_BUILD) message( - WARNING "Failed to find sphinx, documentation will not be generated.") + WARNING + "Failed to find sphinx, documentation will not be generated." + ) else(NOT SPHINX_BUILD) - if(NOT TARGET sphinx-doc) - add_custom_target(sphinx-doc ALL - COMMENT "Generating sphinx documentation") + add_custom_target( + sphinx-doc + ALL + COMMENT "Generating sphinx documentation" + ) endif() if(MSVC) # FIXME: it is impossible to trigger documentation installation at @@ -52,7 +58,8 @@ macro(SPHINX_SETUP) ${PYTHON_EXECUTABLE} ${SPHINX_BUILD} -b html ${CMAKE_CURRENT_BINARY_DIR}/sphinx ${CMAKE_CURRENT_BINARY_DIR}/sphinx-html - COMMENT "Generating sphinx documentation") + COMMENT "Generating sphinx documentation" + ) elseif(APPLE) # THE DYLD_LIBRARY_PATH should be completed to run the sphinx command. # otherwise some symbols won't be found. @@ -65,11 +72,13 @@ macro(SPHINX_SETUP) ${PYTHON_EXECUTABLE} ${SPHINX_BUILD} -b html ${CMAKE_CURRENT_BINARY_DIR}/sphinx ${CMAKE_CURRENT_BINARY_DIR}/sphinx-html - COMMENT "Generating sphinx documentation") + COMMENT "Generating sphinx documentation" + ) if(INSTALL_DOCUMENTATION) install( - CODE "EXECUTE_PROCESS(COMMAND ${CMAKE_MAKE_PROGRAM} sphinx-doc)") + CODE "EXECUTE_PROCESS(COMMAND ${CMAKE_MAKE_PROGRAM} sphinx-doc)" + ) endif(INSTALL_DOCUMENTATION) else() # UNIX # THE LD_LIBRARY_PATH should be completed to run the sphinx command. @@ -83,11 +92,13 @@ macro(SPHINX_SETUP) ${PYTHON_EXECUTABLE} ${SPHINX_BUILD} -b html ${CMAKE_CURRENT_BINARY_DIR}/sphinx ${CMAKE_CURRENT_BINARY_DIR}/sphinx-html - COMMENT "Generating sphinx documentation") + COMMENT "Generating sphinx documentation" + ) if(INSTALL_DOCUMENTATION) install( - CODE "EXECUTE_PROCESS(COMMAND ${CMAKE_MAKE_PROGRAM} sphinx-doc)") + CODE "EXECUTE_PROCESS(COMMAND ${CMAKE_MAKE_PROGRAM} sphinx-doc)" + ) endif(INSTALL_DOCUMENTATION) endif(MSVC) add_dependencies(sphinx-doc ${PROJECT_NAME}-sphinx-doc) @@ -98,26 +109,30 @@ macro(SPHINX_SETUP) ${PYTHON_EXECUTABLE} ${SPHINX_BUILD} -b html ${CMAKE_CURRENT_BINARY_DIR}/sphinx ${CMAKE_CURRENT_BINARY_DIR}/sphinx-html - COMMENT "Generating sphinx documentation") + COMMENT "Generating sphinx documentation" + ) # Clean generated files. set_property( DIRECTORY APPEND - PROPERTY ADDITIONAL_MAKE_CLEAN_FILES - ${PROJECT_BINARY_DIR}/doc/sphinx-html) + PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${PROJECT_BINARY_DIR}/doc/sphinx-html + ) # Install generated files. if(INSTALL_DOCUMENTATION) - install(DIRECTORY ${PROJECT_BINARY_DIR}/doc/sphinx-html - DESTINATION share/doc/${PROJECT_NAME}) + install( + DIRECTORY ${PROJECT_BINARY_DIR}/doc/sphinx-html + DESTINATION share/doc/${PROJECT_NAME} + ) if(EXISTS ${PROJECT_SOURCE_DIR}/doc/pictures) - install(DIRECTORY ${PROJECT_SOURCE_DIR}/doc/pictures - DESTINATION share/doc/${PROJECT_NAME}/sphinx-html) + install( + DIRECTORY ${PROJECT_SOURCE_DIR}/doc/pictures + DESTINATION share/doc/${PROJECT_NAME}/sphinx-html + ) endif(EXISTS ${PROJECT_SOURCE_DIR}/doc/pictures) endif(INSTALL_DOCUMENTATION) - endif(NOT SPHINX_BUILD) list(APPEND LOGGING_WATCHED_VARIABLES SPHINX_BUILD) @@ -130,10 +145,16 @@ endmacro(SPHINX_SETUP) # macro(SPHINX_FINALIZE) if(SPHINX_BUILD) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/sphinx/index.rst.in - ${CMAKE_CURRENT_BINARY_DIR}/sphinx/index.rst @ONLY) + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/sphinx/index.rst.in + ${CMAKE_CURRENT_BINARY_DIR}/sphinx/index.rst + @ONLY + ) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/sphinx/conf.py.in - ${CMAKE_CURRENT_BINARY_DIR}/sphinx/conf.py @ONLY) + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/sphinx/conf.py.in + ${CMAKE_CURRENT_BINARY_DIR}/sphinx/conf.py + @ONLY + ) endif(SPHINX_BUILD) endmacro(SPHINX_FINALIZE) diff --git a/stubs.cmake b/stubs.cmake index b46998471..4773b7510 100644 --- a/stubs.cmake +++ b/stubs.cmake @@ -13,9 +13,7 @@ # You should have received a copy of the GNU General Public License along with # this program. If not, see . -set(CURRENT_FILE_PATH - ${CMAKE_CURRENT_LIST_DIR} - CACHE INTERNAL "") +set(CURRENT_FILE_PATH ${CMAKE_CURRENT_LIST_DIR} CACHE INTERNAL "") # .rst: .. command:: LOAD_STUBGEN([GIT_TAG]) # @@ -35,12 +33,15 @@ macro(LOAD_STUBGEN) # Download at configure time set(STUBGEN_DIR ${CMAKE_CURRENT_BINARY_DIR}/stubgen) - configure_file(${CURRENT_FILE_PATH}/stubgen/CMakeLists.txt.in - stubgen/CMakeLists.txt) + configure_file( + ${CURRENT_FILE_PATH}/stubgen/CMakeLists.txt.in + stubgen/CMakeLists.txt + ) execute_process( COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . RESULT_VARIABLE result - WORKING_DIRECTORY ${STUBGEN_DIR}) + WORKING_DIRECTORY ${STUBGEN_DIR} + ) if(result) message(FATAL_ERROR "CMake step for stubgen failed: ${result}") endif() @@ -48,7 +49,8 @@ macro(LOAD_STUBGEN) execute_process( COMMAND ${CMAKE_COMMAND} --build . RESULT_VARIABLE result - WORKING_DIRECTORY ${STUBGEN_DIR}) + WORKING_DIRECTORY ${STUBGEN_DIR} + ) if(result) message(FATAL_ERROR "Build step for stubgen failed: ${result}") endif() @@ -76,21 +78,30 @@ endmacro(LOAD_STUBGEN) # Where the module is installed # function(GENERATE_STUBS module_path module_name module_install_dir) - if(NOT STUBGEN_MAIN_FILE) message( - FATAL_ERROR "You need to first load the stubgen module via LOAD_STUBGEN.") + FATAL_ERROR + "You need to first load the stubgen module via LOAD_STUBGEN." + ) endif(NOT STUBGEN_MAIN_FILE) # Regex from IsValidTargetName in CMake/Source/cmGeneratorExpression.cxx if(NOT module_path) - string(REGEX REPLACE "[^A-Za-z0-9_.+-]" "_" target_name - "${PROJECT_NAME}-generate_stubs_${module_name}") + string( + REGEX REPLACE + "[^A-Za-z0-9_.+-]" + "_" + target_name + "${PROJECT_NAME}-generate_stubs_${module_name}" + ) else() string( - REGEX - REPLACE "[^A-Za-z0-9_.+-]" "_" target_name - "${PROJECT_NAME}-generate_stubs_${module_path}_${module_name}") + REGEX REPLACE + "[^A-Za-z0-9_.+-]" + "_" + target_name + "${PROJECT_NAME}-generate_stubs_${module_path}_${module_name}" + ) endif() if($ENV{PYTHONPATH}) @@ -111,8 +122,10 @@ function(GENERATE_STUBS module_path module_name module_install_dir) if(WIN32) foreach(py_target IN LISTS optional_args) if(TARGET ${py_target}) - set(_is_lib - "$,SHARED_LIBRARY>") + set( + _is_lib + "$,SHARED_LIBRARY>" + ) set(_target_dir "$") set(_target_path $<${_is_lib}:${_target_dir}> ${_target_path}) endif() @@ -124,18 +137,20 @@ function(GENERATE_STUBS module_path module_name module_install_dir) endif() add_custom_target( - ${target_name} ALL + ${target_name} + ALL COMMAND ${CMAKE_COMMAND} -E env ${ENV_DLL_PATH} ${CMAKE_COMMAND} -E env PYTHONPATH=${PYTHONPATH} "${PYTHON_EXECUTABLE}" "${STUBGEN_MAIN_FILE}" "-o" "${module_path}" "${module_name}" "--boost-python" --ignore-invalid signature "--no-setup-py" "--root-module-suffix" "" - VERBATIM) + VERBATIM + ) foreach(py_target IN LISTS optional_args) if(TARGET ${py_target}) message( STATUS - "generate_stubs: adding dependency on ${py_target}. Stubs will be generated after it is built." + "generate_stubs: adding dependency on ${py_target}. Stubs will be generated after it is built." ) add_dependencies(${target_name} ${py_target}) else(TARGET ${py_target}) @@ -147,11 +162,12 @@ function(GENERATE_STUBS module_path module_name module_install_dir) DIRECTORY ${module_path}/${module_name} DESTINATION ${module_install_dir} FILES_MATCHING - PATTERN "*.pyi") + PATTERN "*.pyi" + ) set_property( TARGET ${target_name} APPEND - PROPERTY ADDITIONAL_CLEAN_FILES FILES_MATCHING PATTERN "*.pyi") - + PROPERTY ADDITIONAL_CLEAN_FILES FILES_MATCHING PATTERN "*.pyi" + ) endfunction(GENERATE_STUBS module_name) diff --git a/swig.cmake b/swig.cmake index 5b83ed49e..5f92944b7 100644 --- a/swig.cmake +++ b/swig.cmake @@ -2,7 +2,8 @@ macro(GENERATE_INCLUDE_FLAGS) get_property( dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - PROPERTY INCLUDE_DIRECTORIES) + PROPERTY INCLUDE_DIRECTORIES + ) set(INCLUDE_FLAGS "") foreach(dir ${dirs}) set(INCLUDE_FLAGS "-I${dir}" ${INCLUDE_FLAGS}) @@ -18,12 +19,18 @@ macro(ADD_SWIG_PYTHON_BINDING FILENAME DIRECTORY) set(outname ${CMAKE_BINARY_DIR}/${DIRECTORY}/${FILENAME}_wrap.cxx) add_custom_command( OUTPUT ${outname} - COMMAND ${SWIG} ARGS -c++ -python -outcurrentdir ${INCLUDE_FLAGS} - ${CMAKE_SOURCE_DIR}/${DIRECTORY}/${FILENAME}.i - MAIN_DEPENDENCY ${FILENAME}.i) + COMMAND ${SWIG} + ARGS + -c++ -python -outcurrentdir ${INCLUDE_FLAGS} + ${CMAKE_SOURCE_DIR}/${DIRECTORY}/${FILENAME}.i + MAIN_DEPENDENCY ${FILENAME}.i + ) set(PYTHON_SWIG_SOURCES ${FILENAME} ${PYTHON_SWIG_SOURCES}) - set(PYTHON_SWIG_STUBS ${CMAKE_BINARY_DIR}/${DIRECTORY}/${FILENAME}_wrap.cxx - ${PYTHON_SWIG_STUBS}) + set( + PYTHON_SWIG_STUBS + ${CMAKE_BINARY_DIR}/${DIRECTORY}/${FILENAME}_wrap.cxx + ${PYTHON_SWIG_STUBS} + ) endmacro(ADD_SWIG_PYTHON_BINDING FILENAME) macro(GENERATE_SWIG_BINDINGS) @@ -41,8 +48,10 @@ macro(BUILD_SWIG_BINDINGS LIBRARIES) add_library(${libname} SHARED ${stubpath}) target_link_libraries(${libname} ${LIBRARIES}) add_dependencies(${libname} generate_python_bindings) - set_target_properties(${libname} PROPERTIES OUTPUT_NAME ${realname} PREFIX - "") + set_target_properties( + ${libname} + PROPERTIES OUTPUT_NAME ${realname} PREFIX "" + ) endforeach() endmacro() @@ -51,7 +60,9 @@ macro(INSTALL_SWIG_BINDINGS PYTHON_SITELIB PACKAGE) install(TARGETS ${target} DESTINATION ${PYTHON_SITELIB}/${PACKAGE}) endforeach() foreach(source ${PYTHON_SWIG_SOURCES}) - install(PROGRAMS ${CMAKE_BINARY_DIR}/binding/${source}.py - DESTINATION ${PYTHON_SITELIB}/${PACKAGE}) + install( + PROGRAMS ${CMAKE_BINARY_DIR}/binding/${source}.py + DESTINATION ${PYTHON_SITELIB}/${PACKAGE} + ) endforeach() endmacro() diff --git a/test.cmake b/test.cmake index aed79eb32..535147700 100644 --- a/test.cmake +++ b/test.cmake @@ -32,15 +32,13 @@ # *test*. unit-test is added and all tests added with if(DEFINED DISABLE_TESTS) message( - AUTHOR_WARNING "DISABLE_TESTS is deprecated. Use BUILD_TESTING instead.") + AUTHOR_WARNING + "DISABLE_TESTS is deprecated. Use BUILD_TESTING instead." + ) if(DISABLE_TESTS) - set(BUILD_TESTING - OFF - CACHE BOOL "") + set(BUILD_TESTING OFF CACHE BOOL "") else() - set(BUILD_TESTING - ON - CACHE BOOL "") + set(BUILD_TESTING ON CACHE BOOL "") endif() endif(DEFINED DISABLE_TESTS) @@ -56,7 +54,8 @@ if(NOT CMAKE_GENERATOR MATCHES "Visual Studio|Xcode" AND NOT TARGET run_tests) add_custom_target( ${PROJECT_NAME}-run_tests COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -V - VERBATIM) + VERBATIM + ) add_dependencies(run_tests ${PROJECT_NAME}-run_tests) endif() @@ -69,8 +68,11 @@ endif(NOT DEFINED ctest_build_tests_exists) # Create target ctest_build_tests if does not exist yet. # macro(CREATE_CTEST_BUILD_TESTS_TARGET) - get_property(ctest_build_tests_exists_value GLOBAL - PROPERTY ctest_build_tests_exists) + get_property( + ctest_build_tests_exists_value + GLOBAL + PROPERTY ctest_build_tests_exists + ) if(NOT BUILD_TESTING) if(NOT ctest_build_tests_exists_value) add_test( @@ -81,7 +83,8 @@ macro(CREATE_CTEST_BUILD_TESTS_TARGET) --target build_tests -- - $ENV{MAKEFLAGS}) + $ENV{MAKEFLAGS} + ) set_property(GLOBAL PROPERTY ctest_build_tests_exists ON) endif(NOT ctest_build_tests_exists_value) endif(NOT BUILD_TESTING) @@ -103,8 +106,11 @@ macro(ADD_UNIT_TEST NAME) add_dependencies(build_tests ${NAME}) if(ENABLE_COVERAGE) - add_test(NAME ${NAME} COMMAND ${KCOV} --include-path=${CMAKE_SOURCE_DIR} - ${KCOV_DIR}/${NAME} ${NAME}) + add_test( + NAME ${NAME} + COMMAND + ${KCOV} --include-path=${CMAKE_SOURCE_DIR} ${KCOV_DIR}/${NAME} ${NAME} + ) else() add_test(NAME ${NAME} COMMAND ${NAME}) endif() @@ -114,17 +120,14 @@ macro(ADD_UNIT_TEST NAME) ${NAME} PROPERTIES ENVIRONMENT - "LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH};DYLD_LIBRARY_PATH=$ENV{DYLD_LIBRARY_PATH}" + "LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH};DYLD_LIBRARY_PATH=$ENV{DYLD_LIBRARY_PATH}" ) endif(APPLE) if(NOT BUILD_TESTING) set_tests_properties(${NAME} PROPERTIES DEPENDS ctest_build_tests) endif(NOT BUILD_TESTING) -endmacro( - ADD_UNIT_TEST - NAME - SOURCE) +endmacro(ADD_UNIT_TEST NAME SOURCE) # .rst: .. command:: COMPUTE_PYTHONPATH (result [MODULES...]) # @@ -156,7 +159,8 @@ function(COMPUTE_PYTHONPATH result) execute_process( COMMAND "${PYTHON_EXECUTABLE}" "-c" "import os; print(os.pathsep)" OUTPUT_VARIABLE PATHSEP - OUTPUT_STRIP_TRAILING_WHITESPACE) + OUTPUT_STRIP_TRAILING_WHITESPACE + ) list(REMOVE_DUPLICATES PYTHONPATH) if(WIN32) @@ -172,9 +176,7 @@ function(COMPUTE_PYTHONPATH result) list(APPEND ENV_VARIABLES "DYLD_LIBRARY_PATH=$ENV{DYLD_LIBRARY_PATH}") endif(APPLE) - set(${result} - ${ENV_VARIABLES} - PARENT_SCOPE) + set(${result} ${ENV_VARIABLES} PARENT_SCOPE) endfunction() # .rst: .. command:: ADD_PYTHON_UNIT_TEST (NAME SOURCE [MODULES...]) @@ -190,15 +192,22 @@ macro(ADD_PYTHON_UNIT_TEST NAME SOURCE) # run this python test to gather C++ coverage of python bindings add_test( NAME ${NAME} - COMMAND ${KCOV} --include-path=${CMAKE_SOURCE_DIR} ${KCOV_DIR}/${NAME} - ${PYTHON_EXECUTABLE} "${PROJECT_SOURCE_DIR}/${SOURCE}") + COMMAND + ${KCOV} --include-path=${CMAKE_SOURCE_DIR} ${KCOV_DIR}/${NAME} + ${PYTHON_EXECUTABLE} "${PROJECT_SOURCE_DIR}/${SOURCE}" + ) # run this python test again, but this time to gather python coverage - add_test(NAME ${NAME}-pycov - COMMAND ${KCOV} --include-path=${CMAKE_SOURCE_DIR} - ${KCOV_DIR}/${NAME} "${PROJECT_SOURCE_DIR}/${SOURCE}") + add_test( + NAME ${NAME}-pycov + COMMAND + ${KCOV} --include-path=${CMAKE_SOURCE_DIR} ${KCOV_DIR}/${NAME} + "${PROJECT_SOURCE_DIR}/${SOURCE}" + ) else() - add_test(NAME ${NAME} COMMAND ${PYTHON_EXECUTABLE} - "${PROJECT_SOURCE_DIR}/${SOURCE}") + add_test( + NAME ${NAME} + COMMAND ${PYTHON_EXECUTABLE} "${PROJECT_SOURCE_DIR}/${SOURCE}" + ) endif() set(MODULES "${ARGN}") # ARGN is not a variable @@ -206,13 +215,12 @@ macro(ADD_PYTHON_UNIT_TEST NAME SOURCE) compute_pythonpath(ENV_VARIABLES ${MODULES}) set_tests_properties(${NAME} PROPERTIES ENVIRONMENT "${ENV_VARIABLES}") if(ENABLE_COVERAGE) - set_tests_properties(${NAME}-pycov PROPERTIES ENVIRONMENT - "${ENV_VARIABLES}") + set_tests_properties( + ${NAME}-pycov + PROPERTIES ENVIRONMENT "${ENV_VARIABLES}" + ) endif() -endmacro( - ADD_PYTHON_UNIT_TEST - NAME - SOURCE) +endmacro(ADD_PYTHON_UNIT_TEST NAME SOURCE) # .rst: .. command:: ADD_PYTHON_MEMORYCHECK_UNIT_TEST (NAME SOURCE [MODULES...]) # @@ -226,7 +234,8 @@ endmacro( # macro(ADD_PYTHON_MEMORYCHECK_UNIT_TEST NAME SOURCE) add_python_memorycheck_unit_test_v2(NAME ${NAME} SOURCE ${SOURCE} MODULES - ${ARGN}) + ${ARGN} + ) endmacro() # ~~~ @@ -258,8 +267,13 @@ macro(ADD_PYTHON_MEMORYCHECK_UNIT_TEST_V2) set(options) set(oneValueArgs NAME SOURCE SUPP) set(multiValueArgs MODULES) - cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" - "${multiValueArgs}" ${ARGN}) + cmake_parse_arguments( + ARGS + "${options}" + "${oneValueArgs}" + "${multiValueArgs}" + ${ARGN} + ) set(TEST_FILE_NAME memorycheck_unit_test_${ARGS_NAME}.cmake) set(PYTHON_TEST_SCRIPT "${PROJECT_SOURCE_DIR}/${ARGS_SOURCE}") @@ -268,7 +282,9 @@ macro(ADD_PYTHON_MEMORYCHECK_UNIT_TEST_V2) endif() configure_file( ${PROJECT_JRL_CMAKE_MODULE_DIR}/memorycheck_unit_test.cmake.in - ${TEST_FILE_NAME} @ONLY) + ${TEST_FILE_NAME} + @ONLY + ) add_test(NAME ${ARGS_NAME} COMMAND ${CMAKE_COMMAND} -P ${TEST_FILE_NAME}) @@ -282,12 +298,11 @@ endmacro() # Add a test called `NAME` that runs an equivalent of ``julia ${SOURCE}``. # macro(ADD_JULIA_UNIT_TEST NAME SOURCE) - add_test(NAME ${NAME} COMMAND ${Julia_EXECUTABLE} - "${PROJECT_SOURCE_DIR}/${SOURCE}") -endmacro( - ADD_JULIA_UNIT_TEST - NAME - SOURCE) + add_test( + NAME ${NAME} + COMMAND ${Julia_EXECUTABLE} "${PROJECT_SOURCE_DIR}/${SOURCE}" + ) +endmacro(ADD_JULIA_UNIT_TEST NAME SOURCE) # DEFINE_UNIT_TEST(NAME LIB) # ---------------------- diff --git a/tracy.cmake b/tracy.cmake index d1f52df42..ee6813a11 100644 --- a/tracy.cmake +++ b/tracy.cmake @@ -41,10 +41,22 @@ # :param TRACY_ENABLE: Controls if tracy macro are empty or call tracy. function(_GENERATE_TRACY_HEADER) set(options) - set(oneValueArgs INCLUDE_DIR HEADER_DIR FILENAME LIBRARY_NAME TRACY_ENABLE) + set( + oneValueArgs + INCLUDE_DIR + HEADER_DIR + FILENAME + LIBRARY_NAME + TRACY_ENABLE + ) set(multiValueArgs) - cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" - ${ARGN}) + cmake_parse_arguments( + ARGS + "${options}" + "${oneValueArgs}" + "${multiValueArgs}" + ${ARGN} + ) # Set variables for configure_file command set(LIBRARY_NAME ${ARGS_LIBRARY_NAME}) @@ -55,15 +67,19 @@ function(_GENERATE_TRACY_HEADER) set(DEFINE_TRACY_ENABLE) endif() - configure_file(${PROJECT_JRL_CMAKE_MODULE_DIR}/tracy.hh.cmake - ${ARGS_INCLUDE_DIR}/${ARGS_HEADER_DIR}/${ARGS_FILENAME} @ONLY) + configure_file( + ${PROJECT_JRL_CMAKE_MODULE_DIR}/tracy.hh.cmake + ${ARGS_INCLUDE_DIR}/${ARGS_HEADER_DIR}/${ARGS_FILENAME} + @ONLY + ) # Install it if requested. if(INSTALL_GENERATED_HEADERS) install( FILES ${ARGS_INCLUDE_DIR}/${ARGS_HEADER_DIR}/${ARGS_FILENAME} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${ARGS_HEADER_DIR} - PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE) + PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE + ) endif() endfunction() @@ -100,7 +116,8 @@ function(_SETUP_TRACY_HEADER) LIBRARY_NAME ${PACKAGE_CPPNAME} TRACY_ENABLE - ${${PACKAGE_CPPNAME}_TRACY_ENABLE}) + ${${PACKAGE_CPPNAME}_TRACY_ENABLE} + ) endfunction() option(${PACKAGE_CPPNAME}_TRACY_ENABLE "Enable Tracy." OFF) diff --git a/uninstall.cmake b/uninstall.cmake index 1d5312ed6..60fd1790f 100644 --- a/uninstall.cmake +++ b/uninstall.cmake @@ -20,27 +20,31 @@ # macro(_SETUP_PROJECT_UNINSTALL) # Detect if the .catkin was created previously - if(NOT DEFINED PACKAGE_CREATES_DOT_CATKIN - OR NOT "${PACKAGE_PREVIOUS_INSTALL_PREFIX}" STREQUAL - "${CMAKE_INSTALL_PREFIX}") - set(PACKAGE_PREVIOUS_INSTALL_PREFIX - "${CMAKE_INSTALL_PREFIX}" - CACHE INTERNAL "Cache install prefix given to the package") + if( + NOT DEFINED PACKAGE_CREATES_DOT_CATKIN + OR + NOT + "${PACKAGE_PREVIOUS_INSTALL_PREFIX}" STREQUAL "${CMAKE_INSTALL_PREFIX}" + ) + set( + PACKAGE_PREVIOUS_INSTALL_PREFIX + "${CMAKE_INSTALL_PREFIX}" + CACHE INTERNAL + "Cache install prefix given to the package" + ) if(EXISTS "${CMAKE_INSTALL_PREFIX}/.catkin") - set(PACKAGE_CREATES_DOT_CATKIN - FALSE - CACHE INTERNAL "") + set(PACKAGE_CREATES_DOT_CATKIN FALSE CACHE INTERNAL "") else() - set(PACKAGE_CREATES_DOT_CATKIN - TRUE - CACHE INTERNAL "") + set(PACKAGE_CREATES_DOT_CATKIN TRUE CACHE INTERNAL "") endif() endif() # FIXME: it is utterly stupid to rely on the install manifest. Can't we just # remember what we install ?! configure_file( "${CMAKE_CURRENT_LIST_DIR}/cmake_uninstall.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake" @ONLY) + "${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake" + @ONLY + ) if(NOT TARGET uninstall) add_custom_target(uninstall) @@ -49,12 +53,15 @@ macro(_SETUP_PROJECT_UNINSTALL) ${PROJECT_NAME}-uninstall "${CMAKE_COMMAND}" -DPACKAGE_CREATES_DOT_CATKIN=${PACKAGE_CREATES_DOT_CATKIN} -P - "${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake") + "${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake" + ) add_dependencies(uninstall ${PROJECT_NAME}-uninstall) configure_file( "${CMAKE_CURRENT_LIST_DIR}/cmake_reinstall.cmake.in" - "${PROJECT_BINARY_DIR}/cmake/cmake_reinstall.cmake.configured" @ONLY) + "${PROJECT_BINARY_DIR}/cmake/cmake_reinstall.cmake.configured" + @ONLY + ) if(DEFINED CMAKE_BUILD_TYPE) file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/cmake/${CMAKE_BUILD_TYPE}") else(DEFINED CMAKE_BUILD_TYPE) @@ -63,9 +70,10 @@ macro(_SETUP_PROJECT_UNINSTALL) endforeach() endif(DEFINED CMAKE_BUILD_TYPE) file( - GENERATE - OUTPUT "${PROJECT_BINARY_DIR}/cmake/$/cmake_reinstall.cmake" - INPUT "${PROJECT_BINARY_DIR}/cmake/cmake_reinstall.cmake.configured") + GENERATE OUTPUT + "${PROJECT_BINARY_DIR}/cmake/$/cmake_reinstall.cmake" + INPUT "${PROJECT_BINARY_DIR}/cmake/cmake_reinstall.cmake.configured" + ) if(NOT TARGET reinstall) add_custom_target(reinstall) @@ -73,7 +81,8 @@ macro(_SETUP_PROJECT_UNINSTALL) add_custom_target( ${PROJECT_NAME}-reinstall "${CMAKE_COMMAND}" -P - "${PROJECT_BINARY_DIR}/cmake/$/cmake_reinstall.cmake") + "${PROJECT_BINARY_DIR}/cmake/$/cmake_reinstall.cmake" + ) add_dependencies(reinstall ${PROJECT_NAME}-reinstall) endmacro(_SETUP_PROJECT_UNINSTALL) @@ -84,5 +93,6 @@ if(DEFINED CMAKE_CONFIGURATION_TYPES) set(UNINSTALL_CONFIG_ARG "--config \${CMAKE_INSTALL_CONFIG_NAME}") endif() install( - CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" --build \"${PROJECT_BINARY_DIR}\" ${UNINSTALL_CONFIG_ARG} --target uninstall)" + CODE + "execute_process(COMMAND \"${CMAKE_COMMAND}\" --build \"${PROJECT_BINARY_DIR}\" ${UNINSTALL_CONFIG_ARG} --target uninstall)" ) diff --git a/version-script.cmake b/version-script.cmake index 335e4a482..611e07d0d 100644 --- a/version-script.cmake +++ b/version-script.cmake @@ -29,15 +29,23 @@ endif() macro(_CHECK_VERSION_SCRIPT_SUPPORT) set(VERSION_SCRIPT "${PROJECT_JRL_CMAKE_MODULE_DIR}/version-script-test.lds") if(COMMAND check_linker_flag) - check_linker_flag("C" "-Wl,--version-script=${VERSION_SCRIPT}" - HAS_VERSION_SCRIPT_SUPPORT) + check_linker_flag( + "C" + "-Wl,--version-script=${VERSION_SCRIPT}" + HAS_VERSION_SCRIPT_SUPPORT + ) else() - check_c_compiler_flag("-Wl,--version-script=${VERSION_SCRIPT}" - HAS_VERSION_SCRIPT_SUPPORT) + check_c_compiler_flag( + "-Wl,--version-script=${VERSION_SCRIPT}" + HAS_VERSION_SCRIPT_SUPPORT + ) endif() - set(_HAS_VERSION_SCRIPT_SUPPORT - ${HAS_VERSION_SCRIPT_SUPPORT} - CACHE INTERNAL "Linker supports version scripts") + set( + _HAS_VERSION_SCRIPT_SUPPORT + ${HAS_VERSION_SCRIPT_SUPPORT} + CACHE INTERNAL + "Linker supports version scripts" + ) endmacro(_CHECK_VERSION_SCRIPT_SUPPORT) # .rst: .. command:: ADD_VERSION_SCRIPT(TARGET VERSION_SCRIPT) @@ -63,7 +71,8 @@ macro(ADD_VERSION_SCRIPT TARGET VERSION_SCRIPT) set_property( TARGET ${TARGET} APPEND_STRING - PROPERTY LINK_FLAGS " -Wl,--version-script=${VERSION_SCRIPT}") + PROPERTY LINK_FLAGS " -Wl,--version-script=${VERSION_SCRIPT}" + ) set_target_properties(${TARGET} PROPERTIES LINK_DEPENDS ${VERSION_SCRIPT}) endif() endif() diff --git a/version.cmake b/version.cmake index faa666156..ffc79730c 100644 --- a/version.cmake +++ b/version.cmake @@ -17,12 +17,8 @@ function(_COMPUTE_VERSION_FROM_DOT_VERSION_FILE) if(EXISTS ${PROJECT_SOURCE_DIR}/.version) # Yes, use it. This is a stable version. file(STRINGS .version _PROJECT_VERSION) - set(PROJECT_VERSION - ${_PROJECT_VERSION} - PARENT_SCOPE) - set(PROJECT_STABLE - TRUE - PARENT_SCOPE) + set(PROJECT_VERSION ${_PROJECT_VERSION} PARENT_SCOPE) + set(PROJECT_STABLE TRUE PARENT_SCOPE) message(STATUS "Package version (.version): ${_PROJECT_VERSION}") endif(EXISTS ${PROJECT_SOURCE_DIR}/.version) endfunction() @@ -36,7 +32,8 @@ function(_COMPUTE_VERSION_FROM_GIT_DESCRIBE) COMMAND ${GIT} rev-parse --git-dir OUTPUT_VARIABLE GIT_PROJECT_DIR WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - OUTPUT_STRIP_TRAILING_WHITESPACE) + OUTPUT_STRIP_TRAILING_WHITESPACE + ) set(GIT_PROJECT_DIR "${PROJECT_SOURCE_DIR}/${GIT_PROJECT_DIR}") if(IS_DIRECTORY "${GIT_PROJECT_DIR}/shallow") @@ -48,7 +45,7 @@ function(_COMPUTE_VERSION_FROM_GIT_DESCRIBE) # EXECUTE_PROCESS(COMMAND ${GIT} fetch --unshallow) message( WARNING - "It appears that your git repository is a shallow copy, meaning that the history has been truncated\n. + "It appears that your git repository is a shallow copy, meaning that the history has been truncated\n. Please consider updating your git repository with `git fetch --unshallow` in order to download the full history with tags to recover the current release version." ) endif(IS_SHALLOW) @@ -63,7 +60,8 @@ function(_COMPUTE_VERSION_FROM_GIT_DESCRIBE) RESULT_VARIABLE GIT_DESCRIBE_RESULT OUTPUT_VARIABLE GIT_DESCRIBE_OUTPUT ERROR_VARIABLE GIT_DESCRIBE_ERROR - OUTPUT_STRIP_TRAILING_WHITESPACE) + OUTPUT_STRIP_TRAILING_WHITESPACE + ) # Run diff-index to check whether the tree is clean or not. execute_process( @@ -72,13 +70,12 @@ function(_COMPUTE_VERSION_FROM_GIT_DESCRIBE) RESULT_VARIABLE GIT_DIFF_INDEX_RESULT OUTPUT_VARIABLE GIT_DIFF_INDEX_OUTPUT ERROR_VARIABLE GIT_DIFF_INDEX_ERROR - OUTPUT_STRIP_TRAILING_WHITESPACE) + OUTPUT_STRIP_TRAILING_WHITESPACE + ) # Check if the tree is clean. if(GIT_DIFF_INDEX_RESULT OR GIT_DIFF_INDEX_OUTPUT) - set(PROJECT_DIRTY - TRUE - PARENT_SCOPE) + set(PROJECT_DIRTY TRUE PARENT_SCOPE) endif() # Check if git describe worked and store the returned version number. @@ -92,9 +89,7 @@ function(_COMPUTE_VERSION_FROM_GIT_DESCRIBE) endif() if(_PROJECT_VERSION) - set(PROJECT_VERSION - ${_PROJECT_VERSION} - PARENT_SCOPE) + set(PROJECT_VERSION ${_PROJECT_VERSION} PARENT_SCOPE) endif() # If there is a dash in the version number, it is an unstable release, @@ -102,13 +97,9 @@ function(_COMPUTE_VERSION_FROM_GIT_DESCRIBE) # 0.2.4-1-dg43 is unstable. string(REGEX MATCH "-" PROJECT_STABLE "${_PROJECT_VERSION}") if(NOT PROJECT_STABLE STREQUAL -) - set(PROJECT_STABLE - TRUE - PARENT_SCOPE) + set(PROJECT_STABLE TRUE PARENT_SCOPE) else() - set(PROJECT_STABLE - FALSE - PARENT_SCOPE) + set(PROJECT_STABLE FALSE PARENT_SCOPE) endif() message(STATUS "Package version (git describe): ${_PROJECT_VERSION}") @@ -120,13 +111,16 @@ endfunction() function(_COMPUTE_VERSION_FROM_ROS_PACKAGE_XML_FILE) if(EXISTS ${PROJECT_SOURCE_DIR}/package.xml) file(READ "${PROJECT_SOURCE_DIR}/package.xml" PACKAGE_XML) - string(REGEX REPLACE "^.*(.*).*$" "\\1" - _PACKAGE_XML_VERSION ${PACKAGE_XML}) + string( + REGEX REPLACE + "^.*(.*).*$" + "\\1" + _PACKAGE_XML_VERSION + ${PACKAGE_XML} + ) string(STRIP ${_PACKAGE_XML_VERSION} PACKAGE_XML_VERSION) if(NOT "${PACKAGE_XML_VERSION}" STREQUAL "") - set(PROJECT_VERSION - ${PACKAGE_XML_VERSION} - PARENT_SCOPE) + set(PROJECT_VERSION ${PACKAGE_XML_VERSION} PARENT_SCOPE) endif(NOT "${PACKAGE_XML_VERSION}" STREQUAL "") message(STATUS "Package version (ROS package.xml): ${PACKAGE_XML_VERSION}") endif(EXISTS ${PROJECT_SOURCE_DIR}/package.xml) @@ -206,8 +200,13 @@ macro(VERSION_COMPUTE) endif() if(NOT DEFINED PROJECT_VERSION_COMPUTATION_METHODS) - list(APPEND PROJECT_VERSION_COMPUTATION_METHODS "ROS_PACKAGE_XML_FILE" - "DOT_VERSION_FILE" "GIT_DESCRIBE") + list( + APPEND + PROJECT_VERSION_COMPUTATION_METHODS + "ROS_PACKAGE_XML_FILE" + "DOT_VERSION_FILE" + "GIT_DESCRIBE" + ) endif() foreach(_computation_method ${PROJECT_VERSION_COMPUTATION_METHODS}) @@ -221,7 +220,7 @@ macro(VERSION_COMPUTE) else() message( AUTHOR_WARNING - "${_computation_method} is not a valid method to compute the project version." + "${_computation_method} is not a valid method to compute the project version." ) endif() endif(NOT PROJECT_VERSION) @@ -235,18 +234,25 @@ macro(VERSION_COMPUTE) # Set PROJECT_VERSION_{MAJOR,MINOR,PATCH} variables if(PROJECT_VERSION) # Compute the major, minor and patch version of the project - if(NOT DEFINED PROJECT_VERSION_MAJOR - AND NOT DEFINED PROJECT_VERSION_MINOR - AND NOT DEFINED PROJECT_VERSION_PATCH) + if( + NOT DEFINED PROJECT_VERSION_MAJOR + AND NOT DEFINED PROJECT_VERSION_MINOR + AND NOT DEFINED PROJECT_VERSION_PATCH + ) split_version_number(${PROJECT_VERSION} PROJECT_VERSION_MAJOR - PROJECT_VERSION_MINOR PROJECT_VERSION_PATCH) + PROJECT_VERSION_MINOR PROJECT_VERSION_PATCH + ) endif() endif() - endmacro() -macro(SPLIT_VERSION_NUMBER VERSION VERSION_MAJOR_VAR VERSION_MINOR_VAR - VERSION_PATCH_VAR) +macro( + SPLIT_VERSION_NUMBER + VERSION + VERSION_MAJOR_VAR + VERSION_MINOR_VAR + VERSION_PATCH_VAR +) # Compute the major, minor and patch version of the project if(${VERSION} MATCHES UNKNOWN) set(${VERSION_MAJOR_VAR} UNKNOWN) diff --git a/xacro.cmake b/xacro.cmake index e79d6335d..7641f6ccd 100644 --- a/xacro.cmake +++ b/xacro.cmake @@ -44,22 +44,18 @@ macro(RUN_XACRO INPUT OUTPUT) add_custom_command( OUTPUT ${OUTPUT} - COMMAND ${_xacro_py} ARGS ${XACRO_OPTIONS} -o ${OUTPUT} ${INPUT} + COMMAND ${_xacro_py} + ARGS ${XACRO_OPTIONS} -o ${OUTPUT} ${INPUT} MAIN_DEPENDENCY ${INPUT} - COMMENT "Generating ${OUTPUT}") + COMMENT "Generating ${OUTPUT}" + ) list(APPEND ALL_GENERATED_URDF ${OUTPUT}) # Clean generated files. - set_property( - DIRECTORY - APPEND - PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${OUTPUT}) + set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${OUTPUT}) list(APPEND LOGGING_WATCHED_VARIABLES ALL_GENERATED_URDF) -endmacro( - RUN_XACRO - INPUT - OUTPUT) +endmacro(RUN_XACRO INPUT OUTPUT) # .rst: .. command:: GENERATE_URDF_FILE (FILENAME EXTENSION) # @@ -82,19 +78,20 @@ macro(GENERATE_URDF_FILE FILENAME EXTENSION) if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${FILENAME}.xacro.in) message( FATAL_ERROR - "cannot find \"${FILENAME}.xacro\" or \"${FILENAME}.xacro.in\"") + "cannot find \"${FILENAME}.xacro\" or \"${FILENAME}.xacro.in\"" + ) endif(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${FILENAME}.xacro.in) set(_XACRO_FILE_ ${CMAKE_CURRENT_BINARY_DIR}/${FILENAME}.xacro) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${FILENAME}.xacro.in - ${_XACRO_FILE_} @ONLY) + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/${FILENAME}.xacro.in + ${_XACRO_FILE_} + @ONLY + ) # MESSAGE("Configuring ${FILENAME}.xacro.in") else(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${FILENAME}.xacro) set(_XACRO_FILE_ ${CMAKE_CURRENT_SOURCE_DIR}/${FILENAME}.xacro) endif(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${FILENAME}.xacro) run_xacro(${_XACRO_FILE_} ${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_FILE}) -endmacro( - GENERATE_URDF_FILE - FILENAME - CONFIGURE) +endmacro(GENERATE_URDF_FILE FILENAME CONFIGURE)