Skip to content

Commit

Permalink
Merge pull request #731 from ManifoldFR/topic/gersemi-add-defs-and-fo…
Browse files Browse the repository at this point in the history
…rmat

Add current directory (and subdirectories) to gersemi defs, format all
  • Loading branch information
jcarpent authored Dec 20, 2024
2 parents 8456ad4 + df74719 commit acc238a
Show file tree
Hide file tree
Showing 39 changed files with 363 additions and 265 deletions.
2 changes: 1 addition & 1 deletion .docs/examples/minimal-hpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set(PROJECT_DESCRIPTION "A HPP project example")
# hpp.cmake includes base.cmake.
include(cmake/hpp.cmake)

compute_project_args(PROJECT_ARGS LANGUAGES CXX)
COMPUTE_PROJECT_ARGS(PROJECT_ARGS LANGUAGES CXX)
project(${PROJECT_NAME} ${PROJECT_ARGS})

# Configure the build of your project here add_subdirectory(src)
10 changes: 8 additions & 2 deletions .docs/examples/minimal-with-packages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,17 @@ include(cmake/base.cmake)
project(${PROJECT_NAME} CXX)

# Add a required dependency
add_project_dependency(MyDependency REQUIRED)
ADD_PROJECT_DEPENDENCY(MyDependency REQUIRED)

# Another example to show that arguments can be passed down to the underlying
# find_package call
add_project_dependency(Boost 1.50 REQUIRED COMPONENT timer)
ADD_PROJECT_DEPENDENCY(
Boost
1.50
REQUIRED
COMPONENT
timer
)

add_library(myLibrary ${MY_SOURCES})
target_link_libraries(myLibrary MyDependency::MyAwesomeLib Boost::timer)
Expand Down
1 change: 1 addition & 0 deletions .gersemirc
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
definitions: [./]
indent: 2
warn_about_unknown_commands: false
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ a7abe2312a94b28f01173d6db5f74bb26c934e10
# switch to gersemi and pre-commit run -a (ManifoldFR, 2024-10-23)
f743a57ca5b83cc19669cac3d3541c23ea89a74a
ad86c1842091800eeff5fdcb32e766ac2338e50c
# add ./ to gersemi defs and pre-commit run -a (ManifoldFR, 2024-12-19)
c37b94e619480d12a68d1f045df184534025b7ef
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
include(GNUInstallDirs)
include(package-config.cmake)
set(PROJECT_JRL_CMAKE_MODULE_DIR ${CMAKE_CURRENT_LIST_DIR})
setup_project_package_finalize()
SETUP_PROJECT_PACKAGE_FINALIZE()

# Add a dummy library with a useful INTERFACE_INCLUDE_DIRECTORIES
add_library(${PROJECT_NAME} INTERFACE)
Expand Down
2 changes: 1 addition & 1 deletion _unittests/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set(PROJECT_USE_CMAKE_EXPORT TRUE)

include(../../base.cmake)

compute_project_args(PROJECT_ARGS LANGUAGES CXX)
COMPUTE_PROJECT_ARGS(PROJECT_ARGS LANGUAGES CXX)
project(${PROJECT_NAME} ${PROJECT_ARGS})

set(${PROJECT_NAME}_HEADERS include/jrl_cmakemodule/lib.hh)
Expand Down
4 changes: 2 additions & 2 deletions _unittests/dependency/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ include(../macros.cmake)

include(../../base.cmake)

compute_project_args(PROJECT_ARGS LANGUAGES CXX)
COMPUTE_PROJECT_ARGS(PROJECT_ARGS LANGUAGES CXX)
project(${PROJECT_NAME} ${PROJECT_ARGS})

add_project_dependency(jrl-cmakemodules-cpp REQUIRED)
ADD_PROJECT_DEPENDENCY(jrl-cmakemodules-cpp REQUIRED)

check_exist_target(jrl-cmakemodules-cpp::jrl_cmakemodule_lib "")

Expand Down
6 changes: 3 additions & 3 deletions _unittests/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ include(../macros.cmake)
include(../../base.cmake)
include(../../python.cmake)

compute_project_args(PROJECT_ARGS)
COMPUTE_PROJECT_ARGS(PROJECT_ARGS)
project(${PROJECT_NAME} ${PROJECT_ARGS})
findpython()
FINDPYTHON()

check_exist_variable(PYTHON_SITELIB "")

python_install_on_site(jrl_cmakemodule python.py)
PYTHON_INSTALL_ON_SITE(jrl_cmakemodule python.py)
60 changes: 36 additions & 24 deletions _unittests/test_pkg-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,49 @@ macro(UNSET_TEST_VARS)
unset(PKG_CONFIG_STRING_NOSPACE)
endmacro()

unset_test_vars()
_parse_pkg_config_string("my-package > 0.4" PKG_LIB_NAME PKG_PREFIX
PKG_CONFIG_STRING_NOSPACE
UNSET_TEST_VARS()
_PARSE_PKG_CONFIG_STRING(
"my-package > 0.4"
PKG_LIB_NAME
PKG_PREFIX
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}")
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
UNSET_TEST_VARS()
_PARSE_PKG_CONFIG_STRING(
"my-package >= 0.4"
PKG_LIB_NAME
PKG_PREFIX
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}")
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
UNSET_TEST_VARS()
_PARSE_PKG_CONFIG_STRING(
"my-package"
PKG_LIB_NAME
PKG_PREFIX
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}")
EXPECT_STREQUAL("my-package" "${PKG_LIB_NAME}")
EXPECT_STREQUAL("MY_PACKAGE" "${PKG_PREFIX}")
EXPECT_STREQUAL("my-package" "${PKG_CONFIG_STRING_NOSPACE}")

# it the input does not have spaces around the operator, the operator is
# considered as being part of the library name. This is expected and consistent
# 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
UNSET_TEST_VARS()
_PARSE_PKG_CONFIG_STRING(
"my-package>=0.4"
PKG_LIB_NAME
PKG_PREFIX
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}")
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}")
29 changes: 16 additions & 13 deletions base.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -207,15 +207,18 @@ message(STATUS "Configuring \"${PROJECT_NAME}\" (${PROJECT_URL})")

# If the project version number is not set, compute it automatically.
if(NOT DEFINED PROJECT_VERSION)
version_compute()
VERSION_COMPUTE()
else()
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
SPLIT_VERSION_NUMBER(
${PROJECT_VERSION}
PROJECT_VERSION_MAJOR
PROJECT_VERSION_MINOR
PROJECT_VERSION_PATCH
)
endif()
endif()
Expand Down Expand Up @@ -258,7 +261,7 @@ if(PROJECT_AUTO_RUN_FINALIZE)
JRL_CMAKEMODULE_LOGGING_FILENAME
"${PROJECT_JRL_CMAKE_BINARY_DIR}/config.log"
)
setup_project_finalize()
SETUP_PROJECT_FINALIZE()
set(CMAKE_CURRENT_LIST_DIR "") # restore value
set(JRL_CMAKEMODULE_LOGGING_FILENAME "") # restore value
endif()
Expand Down Expand Up @@ -309,7 +312,7 @@ endmacro(_ADD_TO_LIST_IF_NOT_PRESENT LIST VALUE)
#
macro(_CONCATENATE_ARGUMENTS OUTPUT SEPARATOR)
foreach(I RANGE 2 ${ARGC})
_add_to_list("${OUTPUT}" "${ARGV${I}}" "${SEPARATOR}")
_ADD_TO_LIST("${OUTPUT}" "${ARGV${I}}" "${SEPARATOR}")
endforeach(I RANGE 2 ${ARGC})
message(${${OUTPUT}})
endmacro(_CONCATENATE_ARGUMENTS OUTPUT)
Expand Down Expand Up @@ -348,19 +351,19 @@ endmacro(SETUP_PROJECT)
#
macro(SETUP_PROJECT_FINALIZE)
if(INSTALL_PKG_CONFIG_FILE)
_setup_project_pkg_config_finalize()
_SETUP_PROJECT_PKG_CONFIG_FINALIZE()
endif(INSTALL_PKG_CONFIG_FILE)
_setup_project_documentation_finalize()
_setup_project_header_finalize()
_setup_coverage_finalize()
_setup_debian()
_SETUP_PROJECT_DOCUMENTATION_FINALIZE()
_SETUP_PROJECT_HEADER_FINALIZE()
_SETUP_COVERAGE_FINALIZE()
_SETUP_DEBIAN()
# Install data if needed
_install_project_data()
_INSTALL_PROJECT_DATA()
_install_project_ros2_ament_files()

logging_finalize()
LOGGING_FINALIZE()
if(PROJECT_USE_CMAKE_EXPORT)
setup_project_package_finalize()
SETUP_PROJECT_PACKAGE_FINALIZE()
endif()
endmacro(SETUP_PROJECT_FINALIZE)

Expand Down
18 changes: 9 additions & 9 deletions boost.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ macro(SEARCH_FOR_BOOST_PYTHON)
set(BOOST_PYTHON_REQUIRED REQUIRED)
endif(SEARCH_FOR_BOOST_PYTHON_ARGS_REQUIRED)

set_boost_default_options()
SET_BOOST_DEFAULT_OPTIONS()

if(NOT PYTHON_EXECUTABLE)
message(
Expand All @@ -120,7 +120,7 @@ macro(SEARCH_FOR_BOOST_PYTHON)
)
set(BOOST_PYTHON_FOUND FALSE)
foreach(BOOST_PYTHON_COMPONENT ${BOOST_PYTHON_COMPONENT_LIST})
search_for_boost_component(${BOOST_PYTHON_COMPONENT} BOOST_PYTHON_FOUND)
SEARCH_FOR_BOOST_COMPONENT(${BOOST_PYTHON_COMPONENT} BOOST_PYTHON_FOUND)
if(BOOST_PYTHON_FOUND)
set(BOOST_PYTHON_NAME ${BOOST_PYTHON_COMPONENT})
break()
Expand All @@ -138,8 +138,8 @@ macro(SEARCH_FOR_BOOST_PYTHON)
endif()

if(PYTHON_EXPORT_DEPENDENCY)
install_jrl_cmakemodules_dir("boost")
install_jrl_cmakemodules_file("boost.cmake")
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})"
Expand Down Expand Up @@ -238,7 +238,7 @@ endmacro(TARGET_LINK_BOOST_PYTHON)
# PKG_CONFIG_APPEND_BOOST_LIBS(system filesystem)
#
macro(PKG_CONFIG_APPEND_BOOST_LIBS)
pkg_config_append_library_dir("${Boost_LIBRARY_DIRS}")
PKG_CONFIG_APPEND_LIBRARY_DIR("${Boost_LIBRARY_DIRS}")

foreach(COMPONENT ${ARGN})
string(TOUPPER ${COMPONENT} UPPERCOMPONENT)
Expand All @@ -259,17 +259,17 @@ macro(PKG_CONFIG_APPEND_BOOST_LIBS)
get_filename_component(LIB_NAME ${LIB_PATH} NAME_WE)
string(REGEX REPLACE "^lib" "" LIB_NAME "${LIB_NAME}")
if("${LOWERCOMPONENT}" MATCHES "python")
pkg_config_append_libs_raw(-Wl,-undefined,dynamic_lookup,-l${LIB_NAME})
PKG_CONFIG_APPEND_LIBS_RAW(-Wl,-undefined,dynamic_lookup,-l${LIB_NAME})
else("${LOWERCOMPONENT}" MATCHES "python")
pkg_config_append_libs_raw(-l${LIB_NAME})
PKG_CONFIG_APPEND_LIBS_RAW(-l${LIB_NAME})
endif("${LOWERCOMPONENT}" MATCHES "python")
elseif(WIN32)
get_filename_component(LIB_NAME ${LIB_PATH} NAME)
pkg_config_append_libs_raw("-l${LIB_NAME}")
PKG_CONFIG_APPEND_LIBS_RAW("-l${LIB_NAME}")
else()
get_filename_component(LIB_NAME ${LIB_PATH} NAME_WE)
string(REGEX REPLACE "^lib" "" LIB_NAME "${LIB_NAME}")
pkg_config_append_libs_raw("-l${LIB_NAME}")
PKG_CONFIG_APPEND_LIBS_RAW("-l${LIB_NAME}")
endif(APPLE)
endforeach()
endmacro(PKG_CONFIG_APPEND_BOOST_LIBS)
11 changes: 4 additions & 7 deletions compiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,10 @@ macro(_SETUP_PROJECT_WARNINGS)
/wd4355
)

cxx_flags_by_compiler_frontend(
GNU
${GNU_FLAGS}
MSVC
${MSVC_FLAGS}
OUTPUT
WARNING_CXX_FLAGS_LIST
CXX_FLAGS_BY_COMPILER_FRONTEND(
GNU ${GNU_FLAGS}
MSVC ${MSVC_FLAGS}
OUTPUT WARNING_CXX_FLAGS_LIST
FILTER
)
string(REPLACE ";" " " WARNING_CXX_FLAGS "${WARNING_CXX_FLAGS_LIST}")
Expand Down
6 changes: 4 additions & 2 deletions cpack.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ macro(ADD_CMAKE_DEPENDENCY PKG_CONFIG_STRING)
VERSION
"${PKG_CONFIG_STRING}"
)
_add_to_list(CPACK_INTERNAL_CONFIG_REQUIRES "${LIBRARY_NAME}(>=${VERSION})"
","
_ADD_TO_LIST(
CPACK_INTERNAL_CONFIG_REQUIRES
"${LIBRARY_NAME}(>=${VERSION})"
","
)
endmacro(ADD_CMAKE_DEPENDENCY)

Expand Down
2 changes: 1 addition & 1 deletion cxx11.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ macro(PROJECT_USE_CXX11)
DEPRECATION
"This macro is deprecated. Use CHECK_MINIMAL_CXX_STANDARD instead."
)
check_minimal_cxx_standard(11 REQUIRED)
CHECK_MINIMAL_CXX_STANDARD(11 REQUIRED)
endmacro(PROJECT_USE_CXX11)
Loading

0 comments on commit acc238a

Please sign in to comment.