From 598ee273af2ab79b619a3a606bac00e7f4fdf9f9 Mon Sep 17 00:00:00 2001 From: Jose Luis Rivero Date: Wed, 20 Nov 2019 18:41:14 +0100 Subject: [PATCH 01/69] Use shorter names to make windows happy --- examples/CMakeLists.txt | 14 +++++++------- .../{component_deps => comp_deps}/CMakeLists.txt | 0 examples/{component_deps => comp_deps}/README.md | 0 .../child/CMakeLists.txt | 0 .../child/include/empty.hh | 0 .../parent/CMakeLists.txt | 0 .../parent/include/empty.hh | 0 .../src/AlmostEmpty.cc | 0 .../src/CMakeLists.txt | 0 .../CMakeLists.txt | 0 .../{ign_configure_build => ign_conf}/README.md | 0 .../include/CMakeLists.txt | 0 .../src/CMakeLists.txt | 0 .../test/CMakeLists.txt | 0 14 files changed, 7 insertions(+), 7 deletions(-) rename examples/{component_deps => comp_deps}/CMakeLists.txt (100%) rename examples/{component_deps => comp_deps}/README.md (100%) rename examples/{component_deps => comp_deps}/child/CMakeLists.txt (100%) rename examples/{component_deps => comp_deps}/child/include/empty.hh (100%) rename examples/{component_deps => comp_deps}/parent/CMakeLists.txt (100%) rename examples/{component_deps => comp_deps}/parent/include/empty.hh (100%) rename examples/{component_deps => comp_deps}/src/AlmostEmpty.cc (100%) rename examples/{component_deps => comp_deps}/src/CMakeLists.txt (100%) rename examples/{ign_configure_build => ign_conf}/CMakeLists.txt (100%) rename examples/{ign_configure_build => ign_conf}/README.md (100%) rename examples/{ign_configure_build => ign_conf}/include/CMakeLists.txt (100%) rename examples/{ign_configure_build => ign_conf}/src/CMakeLists.txt (100%) rename examples/{ign_configure_build => ign_conf}/test/CMakeLists.txt (100%) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index b1f138eb..91ee3377 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -8,11 +8,11 @@ if (NOT WIN32 AND EXAMPLE_LCOV_PATH) endif() set(example_directories - ign_configure_build + ign_conf prerelease core_no_deps core_child - component_deps + comp_deps ) if (NOT CMAKE_GENERATOR MATCHES "Visual Studio") list(APPEND example_directories @@ -28,7 +28,7 @@ ign_setup_target_for_codecheck() foreach(example ${example_directories}) set(run_codecheck false) - if (${example} STREQUAL "ign_configure_build") + if (${example} STREQUAL "ign_conf") set(example_tarball_name ignition-minimal-0.1.0.tar.bz2) elseif (${example} STREQUAL "prerelease") set(example_tarball_name ignition-minimal-1.0.0~pre1.tar.bz2) @@ -38,7 +38,7 @@ foreach(example ${example_directories}) elseif (${example} STREQUAL "core_child") set(example_tarball_name ignition-core_child-0.1.0.tar.bz2) set(run_codecheck true) - elseif (${example} STREQUAL "component_deps") + elseif (${example} STREQUAL "comp_deps") set(example_tarball_name ignition-component_deps-0.1.0.tar.bz2) elseif (${example} STREQUAL "use_component_depsA") set(example_tarball_name ignition-use_component_depsa-0.1.0.tar.bz2) @@ -149,13 +149,13 @@ endforeach() foreach (build_type ${build_types}) add_dependencies(core_child_${build_type} core_no_deps_${build_type}) if (TARGET use_component_depsA_${build_type}) - add_dependencies(use_component_depsA_${build_type} component_deps_${build_type}) + add_dependencies(use_component_depsA_${build_type} comp_deps_${build_type}) endif() if (TARGET use_component_depsB_${build_type}) - add_dependencies(use_component_depsB_${build_type} component_deps_${build_type}) + add_dependencies(use_component_depsB_${build_type} comp_deps_${build_type}) endif() if (TARGET use_component_depsC_${build_type}) - add_dependencies(use_component_depsC_${build_type} component_deps_${build_type}) + add_dependencies(use_component_depsC_${build_type} comp_deps_${build_type}) endif() endforeach() diff --git a/examples/component_deps/CMakeLists.txt b/examples/comp_deps/CMakeLists.txt similarity index 100% rename from examples/component_deps/CMakeLists.txt rename to examples/comp_deps/CMakeLists.txt diff --git a/examples/component_deps/README.md b/examples/comp_deps/README.md similarity index 100% rename from examples/component_deps/README.md rename to examples/comp_deps/README.md diff --git a/examples/component_deps/child/CMakeLists.txt b/examples/comp_deps/child/CMakeLists.txt similarity index 100% rename from examples/component_deps/child/CMakeLists.txt rename to examples/comp_deps/child/CMakeLists.txt diff --git a/examples/component_deps/child/include/empty.hh b/examples/comp_deps/child/include/empty.hh similarity index 100% rename from examples/component_deps/child/include/empty.hh rename to examples/comp_deps/child/include/empty.hh diff --git a/examples/component_deps/parent/CMakeLists.txt b/examples/comp_deps/parent/CMakeLists.txt similarity index 100% rename from examples/component_deps/parent/CMakeLists.txt rename to examples/comp_deps/parent/CMakeLists.txt diff --git a/examples/component_deps/parent/include/empty.hh b/examples/comp_deps/parent/include/empty.hh similarity index 100% rename from examples/component_deps/parent/include/empty.hh rename to examples/comp_deps/parent/include/empty.hh diff --git a/examples/component_deps/src/AlmostEmpty.cc b/examples/comp_deps/src/AlmostEmpty.cc similarity index 100% rename from examples/component_deps/src/AlmostEmpty.cc rename to examples/comp_deps/src/AlmostEmpty.cc diff --git a/examples/component_deps/src/CMakeLists.txt b/examples/comp_deps/src/CMakeLists.txt similarity index 100% rename from examples/component_deps/src/CMakeLists.txt rename to examples/comp_deps/src/CMakeLists.txt diff --git a/examples/ign_configure_build/CMakeLists.txt b/examples/ign_conf/CMakeLists.txt similarity index 100% rename from examples/ign_configure_build/CMakeLists.txt rename to examples/ign_conf/CMakeLists.txt diff --git a/examples/ign_configure_build/README.md b/examples/ign_conf/README.md similarity index 100% rename from examples/ign_configure_build/README.md rename to examples/ign_conf/README.md diff --git a/examples/ign_configure_build/include/CMakeLists.txt b/examples/ign_conf/include/CMakeLists.txt similarity index 100% rename from examples/ign_configure_build/include/CMakeLists.txt rename to examples/ign_conf/include/CMakeLists.txt diff --git a/examples/ign_configure_build/src/CMakeLists.txt b/examples/ign_conf/src/CMakeLists.txt similarity index 100% rename from examples/ign_configure_build/src/CMakeLists.txt rename to examples/ign_conf/src/CMakeLists.txt diff --git a/examples/ign_configure_build/test/CMakeLists.txt b/examples/ign_conf/test/CMakeLists.txt similarity index 100% rename from examples/ign_configure_build/test/CMakeLists.txt rename to examples/ign_conf/test/CMakeLists.txt From 287efcb5edbf5b9b4d51277c5fbe3df633a26aef Mon Sep 17 00:00:00 2001 From: Jose Luis Rivero Date: Wed, 20 Nov 2019 19:24:03 +0100 Subject: [PATCH 02/69] Reduce name for core_no_deps --- examples/CMakeLists.txt | 10 +++++----- examples/{core_no_deps => core_nodep}/CMakeLists.txt | 0 examples/{core_no_deps => core_nodep}/README.md | 0 .../include/CMakeLists.txt | 0 .../{core_no_deps => core_nodep}/src/AlmostEmpty.cc | 0 .../{core_no_deps => core_nodep}/src/CMakeLists.txt | 0 .../{core_no_deps => core_nodep}/test/CMakeLists.txt | 0 examples/test_core_child_requires_core_no_deps.bash | 11 +++++------ 8 files changed, 10 insertions(+), 11 deletions(-) rename examples/{core_no_deps => core_nodep}/CMakeLists.txt (100%) rename examples/{core_no_deps => core_nodep}/README.md (100%) rename examples/{core_no_deps => core_nodep}/include/CMakeLists.txt (100%) rename examples/{core_no_deps => core_nodep}/src/AlmostEmpty.cc (100%) rename examples/{core_no_deps => core_nodep}/src/CMakeLists.txt (100%) rename examples/{core_no_deps => core_nodep}/test/CMakeLists.txt (100%) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 91ee3377..7106bb35 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -10,7 +10,7 @@ endif() set(example_directories ign_conf prerelease - core_no_deps + core_nodep core_child comp_deps ) @@ -32,7 +32,7 @@ foreach(example ${example_directories}) set(example_tarball_name ignition-minimal-0.1.0.tar.bz2) elseif (${example} STREQUAL "prerelease") set(example_tarball_name ignition-minimal-1.0.0~pre1.tar.bz2) - elseif (${example} STREQUAL "core_no_deps") + elseif (${example} STREQUAL "core_nodep") set(example_tarball_name ignition-core_no_deps-0.1.0.tar.bz2) set(run_codecheck true) elseif (${example} STREQUAL "core_child") @@ -147,7 +147,7 @@ endforeach() # hard to use DEPENDS in ExternalProject_Add because targets # need to exist before they can be used there foreach (build_type ${build_types}) - add_dependencies(core_child_${build_type} core_no_deps_${build_type}) + add_dependencies(core_child_${build_type} core_nodep_${build_type}) if (TARGET use_component_depsA_${build_type}) add_dependencies(use_component_depsA_${build_type} comp_deps_${build_type}) endif() @@ -159,9 +159,9 @@ foreach (build_type ${build_types}) endif() endforeach() -# test that core_child pkg-config file requires core_no_deps +# test that core_child pkg-config file requires core_nodep if (UNIX) - set(TEST_NAME core_child_requires_core_no_deps) + set(TEST_NAME core_child_requires_core_nodep) string(TIMESTAMP TEST_TIME) configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/junit_pass.xml.in" diff --git a/examples/core_no_deps/CMakeLists.txt b/examples/core_nodep/CMakeLists.txt similarity index 100% rename from examples/core_no_deps/CMakeLists.txt rename to examples/core_nodep/CMakeLists.txt diff --git a/examples/core_no_deps/README.md b/examples/core_nodep/README.md similarity index 100% rename from examples/core_no_deps/README.md rename to examples/core_nodep/README.md diff --git a/examples/core_no_deps/include/CMakeLists.txt b/examples/core_nodep/include/CMakeLists.txt similarity index 100% rename from examples/core_no_deps/include/CMakeLists.txt rename to examples/core_nodep/include/CMakeLists.txt diff --git a/examples/core_no_deps/src/AlmostEmpty.cc b/examples/core_nodep/src/AlmostEmpty.cc similarity index 100% rename from examples/core_no_deps/src/AlmostEmpty.cc rename to examples/core_nodep/src/AlmostEmpty.cc diff --git a/examples/core_no_deps/src/CMakeLists.txt b/examples/core_nodep/src/CMakeLists.txt similarity index 100% rename from examples/core_no_deps/src/CMakeLists.txt rename to examples/core_nodep/src/CMakeLists.txt diff --git a/examples/core_no_deps/test/CMakeLists.txt b/examples/core_nodep/test/CMakeLists.txt similarity index 100% rename from examples/core_no_deps/test/CMakeLists.txt rename to examples/core_nodep/test/CMakeLists.txt diff --git a/examples/test_core_child_requires_core_no_deps.bash b/examples/test_core_child_requires_core_no_deps.bash index b048ea7c..250bd657 100755 --- a/examples/test_core_child_requires_core_no_deps.bash +++ b/examples/test_core_child_requires_core_no_deps.bash @@ -1,13 +1,12 @@ #!/bin/bash if pkg-config ignition-core_child --print-requires \ - | grep ignition-core_no_deps + | grep ignition-core_nodep then - echo Successfully detected ignition-core_no_deps requirement - cp core_child_requires_core_no_deps_pass.xml ../test_results/core_child_requires_core_no_deps.xml + echo Successfully detected ignition-core_nodep requirement + cp core_child_requires_core_nodep_pass.xml ../test_results/core_child_requires_core_nodep.xml exit 0 else - echo Could not detect ignition-core_no_deps requirement - cp core_child_requires_core_no_deps_fail.xml ../test_results/core_child_requires_core_no_deps.xml + echo Could not detect ignition-core_nodep requirement + cp core_child_requires_core_nodep_fail.xml ../test_results/core_child_requires_core_nodep.xml exit 1 fi - From 356070601423c48be5598f940dacfad69193a8e8 Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Wed, 20 Nov 2019 13:05:35 -0800 Subject: [PATCH 03/69] fix test, only folder names have changed, package names are still the same --- examples/test_core_child_requires_core_no_deps.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/test_core_child_requires_core_no_deps.bash b/examples/test_core_child_requires_core_no_deps.bash index 250bd657..8c42fa9d 100755 --- a/examples/test_core_child_requires_core_no_deps.bash +++ b/examples/test_core_child_requires_core_no_deps.bash @@ -1,6 +1,6 @@ #!/bin/bash if pkg-config ignition-core_child --print-requires \ - | grep ignition-core_nodep + | grep ignition-core_no_deps then echo Successfully detected ignition-core_nodep requirement cp core_child_requires_core_nodep_pass.xml ../test_results/core_child_requires_core_nodep.xml From a57fe907c5129caf115139d0a37ac404c374e01d Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Thu, 21 Nov 2019 01:52:14 +0000 Subject: [PATCH 04/69] Close branch ign-cmake2_short_names From 9e8404fc971ef7ea61cd91ad78d4d124c9ba45c0 Mon Sep 17 00:00:00 2001 From: Nate Koenig Date: Fri, 7 Feb 2020 09:06:58 -0800 Subject: [PATCH 05/69] Use mathjax to render equations --- doc/doxygen/api.in | 2 +- doc/doxygen/header.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/doxygen/api.in b/doc/doxygen/api.in index e0724f74..a3f68016 100644 --- a/doc/doxygen/api.in +++ b/doc/doxygen/api.in @@ -1476,7 +1476,7 @@ FORMULA_TRANSPARENT = YES # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. -USE_MATHJAX = NO +USE_MATHJAX = YES # When MathJax is enabled you can set the default output format to be used for # the MathJax output. See the MathJax site (see: diff --git a/doc/doxygen/header.html b/doc/doxygen/header.html index 98561e08..801bba89 100644 --- a/doc/doxygen/header.html +++ b/doc/doxygen/header.html @@ -15,7 +15,7 @@ - + From 417305a52e652f8bea1a4dc482289f4199143fd9 Mon Sep 17 00:00:00 2001 From: Louise Poubel Date: Fri, 14 Feb 2020 01:24:32 +0000 Subject: [PATCH 06/69] Close branch use mathjax From 4ff79d0355fe2337e4588cf374cad63047752659 Mon Sep 17 00:00:00 2001 From: Silvio Traversaro Date: Sun, 22 Mar 2020 15:44:54 +0000 Subject: [PATCH 07/69] Fix use of FindZIP without pkg-config --- cmake/FindZIP.cmake | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/cmake/FindZIP.cmake b/cmake/FindZIP.cmake index 45da5116..2c2cd76a 100644 --- a/cmake/FindZIP.cmake +++ b/cmake/FindZIP.cmake @@ -27,7 +27,7 @@ # ZIP_LIBRARIES The ZIP libraries include(IgnPkgConfig) -ign_pkg_check_modules(ZIP libzip) +ign_pkg_check_modules_quiet(ZIP libzip) # If that failed, then fall back to manual detection. if(NOT ZIP_FOUND) @@ -58,10 +58,9 @@ if(NOT ZIP_FOUND) include(IgnImportTarget) ign_import_target(ZIP) endif() - - include(FindPackageHandleStandardArgs) - find_package_handle_standard_args( - ZIP - REQUIRED_VARS ZIP_FOUND) - endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + ZIP + REQUIRED_VARS ZIP_FOUND) \ No newline at end of file From 9c5b0d99178313ecc272c6db0c4dd9b1fca0ab7e Mon Sep 17 00:00:00 2001 From: Nate Koenig Date: Mon, 6 Apr 2020 11:55:20 -0700 Subject: [PATCH 08/69] Preparing for ign-cmake 2.2.0 release --- CMakeLists.txt | 2 +- Changelog.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bbe069bb..9039bb84 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) #============================================================================ # Initialize the project #============================================================================ -project(ignition-cmake2 VERSION 2.1.1) +project(ignition-cmake2 VERSION 2.2.0) #-------------------------------------- # Initialize the IGNITION_CMAKE_DIR variable with the location of the cmake diff --git a/Changelog.md b/Changelog.md index c9b289f6..2b955f37 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,6 +1,6 @@ ## Ignition CMake 2.x -### Ignition CMake 2.x.x +### Ignition CMake 2.2.0 1. Set viewport for doxygen pages. * [Pull request 167](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/167) From f959d2fb12713ec8544eb2bacc1650bcd89bf9e1 Mon Sep 17 00:00:00 2001 From: Nate Koenig Date: Mon, 6 Apr 2020 13:56:20 -0700 Subject: [PATCH 09/69] Changelog --- Changelog.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Changelog.md b/Changelog.md index 2b955f37..e3840aff 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,21 @@ ### Ignition CMake 2.2.0 +1. Fix use of FindZIP without pkg-config. + * [Pull request 182](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/182) + +1. Use mathjax to render equations. + * [Pull request 181](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/181) + +1. Reduce example names to fix build on Windows + * [Pull request 180](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/180) + +1. Fix doxygen deprecation filter + * [Pull request 160](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/160) + +1. Change the diamond link icon to a material design link + * [Pull request 159](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/159) + 1. Set viewport for doxygen pages. * [Pull request 167](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/167) From 8cb76bc317360536d60d4f0b2918507da6a448c0 Mon Sep 17 00:00:00 2001 From: Nate Koenig Date: Mon, 6 Apr 2020 21:22:28 +0000 Subject: [PATCH 10/69] Close branch cmake2-2-0 From 2a379b78d492a66b5e0fe0858fbf91f1be450422 Mon Sep 17 00:00:00 2001 From: Nate Koenig Date: Mon, 6 Apr 2020 14:24:17 -0700 Subject: [PATCH 11/69] Added tag ignition-cmake2_2.2.0 for changeset 8093f0df9e9e From ebde577636ffdc686a5660ecb5c1db000abe6e0d Mon Sep 17 00:00:00 2001 From: Nate Koenig Date: Mon, 6 Apr 2020 15:32:22 -0700 Subject: [PATCH 12/69] Added tag ignition-cmake2_2.2.0 for changeset 65f0d7e6fa06 From fe27cfd8912ec8b6ad60747c1ee7d28feb145d3a Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Tue, 7 Apr 2020 22:44:23 -0700 Subject: [PATCH 13/69] add test illustrating bug that private dependencies are not specified as Requires.private in pkg-config files --- examples/CMakeLists.txt | 6 ++++ examples/core_child_private/CMakeLists.txt | 8 +++++ examples/core_child_private/README.md | 0 .../core_child_private/include/CMakeLists.txt | 0 .../core_child_private/src/CMakeLists.txt | 6 ++++ examples/core_child_private/src/empty.cc | 17 +++++++++++ .../core_child_private/test/CMakeLists.txt | 0 ...test_core_child_requires_core_no_deps.bash | 30 +++++++++++++++++-- 8 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 examples/core_child_private/CMakeLists.txt create mode 100644 examples/core_child_private/README.md create mode 100644 examples/core_child_private/include/CMakeLists.txt create mode 100644 examples/core_child_private/src/CMakeLists.txt create mode 100644 examples/core_child_private/src/empty.cc create mode 100644 examples/core_child_private/test/CMakeLists.txt diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 7106bb35..562f8235 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -12,6 +12,7 @@ set(example_directories prerelease core_nodep core_child + core_child_private comp_deps ) if (NOT CMAKE_GENERATOR MATCHES "Visual Studio") @@ -38,6 +39,9 @@ foreach(example ${example_directories}) elseif (${example} STREQUAL "core_child") set(example_tarball_name ignition-core_child-0.1.0.tar.bz2) set(run_codecheck true) + elseif (${example} STREQUAL "core_child_private") + set(example_tarball_name ignition-core_child_private-0.1.0.tar.bz2) + set(run_codecheck true) elseif (${example} STREQUAL "comp_deps") set(example_tarball_name ignition-component_deps-0.1.0.tar.bz2) elseif (${example} STREQUAL "use_component_depsA") @@ -148,6 +152,7 @@ endforeach() # need to exist before they can be used there foreach (build_type ${build_types}) add_dependencies(core_child_${build_type} core_nodep_${build_type}) + add_dependencies(core_child_private_${build_type} core_nodep_${build_type}) if (TARGET use_component_depsA_${build_type}) add_dependencies(use_component_depsA_${build_type} comp_deps_${build_type}) endif() @@ -160,6 +165,7 @@ foreach (build_type ${build_types}) endforeach() # test that core_child pkg-config file requires core_nodep +# and that core_child_private pkg-config file requires core_nodep privately if (UNIX) set(TEST_NAME core_child_requires_core_nodep) string(TIMESTAMP TEST_TIME) diff --git a/examples/core_child_private/CMakeLists.txt b/examples/core_child_private/CMakeLists.txt new file mode 100644 index 00000000..180872b2 --- /dev/null +++ b/examples/core_child_private/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) +project(ignition-core_child_private VERSION 0.1.0) +find_package(ignition-cmake2 REQUIRED) +ign_configure_project() +ign_find_package(ignition-core_no_deps PRIVATE REQUIRED) +ign_configure_build(QUIT_IF_BUILD_ERRORS) +ign_create_packages() +ign_create_docs(TAGFILES "${IGNITION-CORE_NO_DEPS_DOXYGEN_TAGFILE} = ${IGNITION-CORE_NO_DEPS_API_URL}") diff --git a/examples/core_child_private/README.md b/examples/core_child_private/README.md new file mode 100644 index 00000000..e69de29b diff --git a/examples/core_child_private/include/CMakeLists.txt b/examples/core_child_private/include/CMakeLists.txt new file mode 100644 index 00000000..e69de29b diff --git a/examples/core_child_private/src/CMakeLists.txt b/examples/core_child_private/src/CMakeLists.txt new file mode 100644 index 00000000..29014808 --- /dev/null +++ b/examples/core_child_private/src/CMakeLists.txt @@ -0,0 +1,6 @@ +ign_get_libsources_and_unittests(sources gtest_sources) +ign_create_core_library(SOURCES ${sources} CXX_STANDARD 11) +target_link_libraries(${PROJECT_LIBRARY_TARGET_NAME} + PRIVATE + ignition-core_no_deps::ignition-core_no_deps) +ign_build_tests(TYPE UNIT SOURCES ${gtest_sources}) diff --git a/examples/core_child_private/src/empty.cc b/examples/core_child_private/src/empty.cc new file mode 100644 index 00000000..762f8d7f --- /dev/null +++ b/examples/core_child_private/src/empty.cc @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + diff --git a/examples/core_child_private/test/CMakeLists.txt b/examples/core_child_private/test/CMakeLists.txt new file mode 100644 index 00000000..e69de29b diff --git a/examples/test_core_child_requires_core_no_deps.bash b/examples/test_core_child_requires_core_no_deps.bash index 8c42fa9d..7129f292 100755 --- a/examples/test_core_child_requires_core_no_deps.bash +++ b/examples/test_core_child_requires_core_no_deps.bash @@ -1,12 +1,36 @@ #!/bin/bash -if pkg-config ignition-core_child --print-requires \ +TEST_STATUS=0 + +if ! pkg-config ignition-core_child --print-requires \ | grep ignition-core_no_deps then - echo Successfully detected ignition-core_nodep requirement + TEST_STATUS=1 +fi + +if pkg-config ignition-core_child --print-requires-private \ + | grep ignition-core_no_deps +then + TEST_STATUS=1 +fi + +if ! pkg-config ignition-core_child_private --print-requires-private \ + | grep ignition-core_no_deps +then + TEST_STATUS=1 +fi + +if pkg-config ignition-core_child_private --print-requires \ + | grep ignition-core_no_deps +then + TEST_STATUS=1 +fi + +if [[ $TEST_STATUS ]] + echo Successfully detected ignition-core_nodep requirements cp core_child_requires_core_nodep_pass.xml ../test_results/core_child_requires_core_nodep.xml exit 0 else - echo Could not detect ignition-core_nodep requirement + echo Could not detect ignition-core_nodep requirements cp core_child_requires_core_nodep_fail.xml ../test_results/core_child_requires_core_nodep.xml exit 1 fi From e4074e46ee7ba0127be3b0d05d20c3fdfcbaf1a8 Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Wed, 8 Apr 2020 01:46:35 -0700 Subject: [PATCH 14/69] fix syntax error in test --- examples/test_core_child_requires_core_no_deps.bash | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/test_core_child_requires_core_no_deps.bash b/examples/test_core_child_requires_core_no_deps.bash index 7129f292..e14cce21 100755 --- a/examples/test_core_child_requires_core_no_deps.bash +++ b/examples/test_core_child_requires_core_no_deps.bash @@ -26,6 +26,7 @@ then fi if [[ $TEST_STATUS ]] +then echo Successfully detected ignition-core_nodep requirements cp core_child_requires_core_nodep_pass.xml ../test_results/core_child_requires_core_nodep.xml exit 0 From 55cf03ac67fcfe4ba1deda891975393bfb7038ac Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Wed, 8 Apr 2020 01:47:41 -0700 Subject: [PATCH 15/69] fix _PKGCONFIG_TYPE variable name --- cmake/IgnUtils.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/IgnUtils.cmake b/cmake/IgnUtils.cmake index c938e18e..bc6dbdcb 100644 --- a/cmake/IgnUtils.cmake +++ b/cmake/IgnUtils.cmake @@ -399,7 +399,7 @@ macro(ign_find_package PACKAGE_NAME) # Append the entry as a string onto the project-wide variable for # whichever requirement type we selected - ign_string_append(PROJECT_${${PACKAGE_NAME}_PKGCONFIG_TYPE} ${${PACKAGE_NAME}_PKGCONFIG_ENTRY}) + ign_string_append(PROJECT_${PROJECT_${PACKAGE_NAME}_PKGCONFIG_TYPE} ${${PACKAGE_NAME}_PKGCONFIG_ENTRY}) endif() From 15c1a5fda20d20bd9a96a775b7ecbfcb4cbd3282 Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Wed, 8 Apr 2020 02:04:09 -0700 Subject: [PATCH 16/69] the test wasn't actually failing to illustrate the problem; fix that with this branch --- ...test_core_child_requires_core_no_deps.bash | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/examples/test_core_child_requires_core_no_deps.bash b/examples/test_core_child_requires_core_no_deps.bash index e14cce21..9febf845 100755 --- a/examples/test_core_child_requires_core_no_deps.bash +++ b/examples/test_core_child_requires_core_no_deps.bash @@ -1,37 +1,54 @@ #!/bin/bash TEST_STATUS=0 +echo +echo Expect ignition-core_child to require ignition-core_no_deps +pkg-config ignition-core_child --print-requires if ! pkg-config ignition-core_child --print-requires \ | grep ignition-core_no_deps then + echo oops TEST_STATUS=1 fi +echo +echo Expect ignition-core_child to not privately require ignition-core_no_deps +pkg-config ignition-core_child --print-requires-private if pkg-config ignition-core_child --print-requires-private \ | grep ignition-core_no_deps then + echo oops TEST_STATUS=1 fi +echo +echo Expect ignition-core_child_private to privately require ignition-core_no_deps +pkg-config ignition-core_child_private --print-requires-private if ! pkg-config ignition-core_child_private --print-requires-private \ | grep ignition-core_no_deps then + echo oops TEST_STATUS=1 fi +echo +echo Expect ignition-core_child_private to not require ignition-core_no_deps +pkg-config ignition-core_child_private --print-requires if pkg-config ignition-core_child_private --print-requires \ | grep ignition-core_no_deps then + echo oops TEST_STATUS=1 fi -if [[ $TEST_STATUS ]] +echo +if [[ $TEST_STATUS -eq 0 ]] then echo Successfully detected ignition-core_nodep requirements cp core_child_requires_core_nodep_pass.xml ../test_results/core_child_requires_core_nodep.xml exit 0 else - echo Could not detect ignition-core_nodep requirements + echo Could not detect all ignition-core_nodep requirements correctly cp core_child_requires_core_nodep_fail.xml ../test_results/core_child_requires_core_nodep.xml exit 1 fi From b540ddcab91226557e09689ede43054d9e25be82 Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Wed, 8 Apr 2020 16:14:08 -0700 Subject: [PATCH 17/69] copyright year --- examples/core_child_private/src/empty.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/core_child_private/src/empty.cc b/examples/core_child_private/src/empty.cc index 762f8d7f..b86f53ac 100644 --- a/examples/core_child_private/src/empty.cc +++ b/examples/core_child_private/src/empty.cc @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2020 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From c2e1033c7ae744e0f8066aef3c285d3dcc4637ae Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Fri, 10 Apr 2020 17:43:21 +0000 Subject: [PATCH 18/69] Close branch pkgconfig_requires_private From 976141e5d6ee266a8f79c33e79454d7f9db52d21 Mon Sep 17 00:00:00 2001 From: Claire Wang Date: Tue, 21 Apr 2020 10:16:33 -0700 Subject: [PATCH 19/69] [ign-cmake2] Add .gitignore (#76) * mv hgignore * add gitignore Signed-off-by: claireyywang --- .gitignore | 7 +++++++ .hgignore | 6 ------ 2 files changed, 7 insertions(+), 6 deletions(-) create mode 100644 .gitignore delete mode 100644 .hgignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..62b9898c --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +# CMake folders +build +build_* + +# OS generated files +.DS_Store +*.swp diff --git a/.hgignore b/.hgignore deleted file mode 100644 index ebd4abe1..00000000 --- a/.hgignore +++ /dev/null @@ -1,6 +0,0 @@ -syntax: glob - -build -build_* -.DS_Store -*.swp From d85faab6e51b98d6427d4773bed4899dd37fd6a1 Mon Sep 17 00:00:00 2001 From: chapulina Date: Wed, 22 Apr 2020 14:30:38 -0700 Subject: [PATCH 20/69] [ign-cmake2] Update BitBucket links (#74) * [ign-cmake2] Update BitBucket links Signed-off-by: Louise Poubel Co-authored-by: Jose Luis Rivero --- CONTRIBUTING.md | 2 +- Changelog.md | 104 ++++++++++++++++++++++----------------------- README.md | 46 ++++++++++---------- tools/doc_check.sh | 2 +- 4 files changed, 77 insertions(+), 77 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6877dd26..147239ce 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1 +1 @@ -See the [Ignition Robotics contributing guide](https://bitbucket.org/ignitionrobotics/ign-gazebo/src/default/CONTRIBUTING.md). +See the [Ignition Robotics contributing guide](https://ignitionrobotics.org/docs/all/contributing). diff --git a/Changelog.md b/Changelog.md index e3840aff..23525a83 100644 --- a/Changelog.md +++ b/Changelog.md @@ -3,105 +3,105 @@ ### Ignition CMake 2.2.0 1. Fix use of FindZIP without pkg-config. - * [Pull request 182](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/182) + * [BitBucket pull request 182](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/182) 1. Use mathjax to render equations. - * [Pull request 181](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/181) + * [BitBucket pull request 181](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/181) 1. Reduce example names to fix build on Windows - * [Pull request 180](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/180) + * [BitBucket pull request 180](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/180) 1. Fix doxygen deprecation filter - * [Pull request 160](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/160) + * [BitBucket pull request 160](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/160) 1. Change the diamond link icon to a material design link - * [Pull request 159](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/159) + * [BitBucket pull request 159](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/159) 1. Set viewport for doxygen pages. - * [Pull request 167](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/167) + * [BitBucket pull request 167](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/167) 1. Use upstream `CURL::libcurl` imported target in FindIgnCURL.cmake if available. - * [Pull request 175](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/175) + * [BitBucket pull request 175](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/175) 1. Avoid hardcoding /machine:x64 flag on 64-bit on MSVC. - * [Pull request 171](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/171) - * [Pull request 168](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/168) + * [BitBucket pull request 171](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/171) + * [BitBucket pull request 168](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/168) 1. FindIgnOGRE2: fix include paths for new directory structure. - * [Pull request 170](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/170) - * [Pull request 157](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/157) + * [BitBucket pull request 170](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/170) + * [BitBucket pull request 157](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/157) 1. Support for custom vcpkg ogre2 windows port (backport of PR 155). - * [Pull request 161](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/161) - * [Pull request 155](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/155) + * [BitBucket pull request 161](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/161) + * [BitBucket pull request 155](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/155) 1. IgnConfigureBuild: only `add_subdirectory(test)` if `BUILD_TESTING` is ON - * [Pull request 169](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/169) + * [BitBucket pull request 169](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/169) 1. Add FindIgnBullet cmake module. - * [Pull request 162](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/162) + * [BitBucket pull request 162](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/162) ### Ignition CMake 2.1.1 (2019-08-07) 1. Turn on doxygen warnings, add CI script to check for doxygen warnings. - * [Pull request 158](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/158) + * [BitBucket pull request 158](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/158) ### Ignition CMake 2.1.0 (2019-05-17) 1. Fixes for vcpkg ogre 1.11 version - * [Pull request 152](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/152) + * [BitBucket pull request 152](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/152) 1. Add benchmark aggregation functionality - * [Pull request 148](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/148) - * [Pull request 149](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/149) + * [BitBucket pull request 148](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/148) + * [BitBucket pull request 149](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/149) 1. Use `PRIVATE_FOR` to skip cmake dependencies in addition to pkg-config - * [Pull request 147](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/147) + * [BitBucket pull request 147](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/147) 1. `upload_doc.sh`: actually use dry-run, and allow the user to pass in a 'y' or 'n' - * [Pull request 146](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/146) + * [BitBucket pull request 146](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/146) 1. Set favicon - * [Pull request 145](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/145) + * [BitBucket pull request 145](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/145) 1. Fix tagfile generation by preventing the inclusion of tutorials - * [Pull request 142](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/142) + * [BitBucket pull request 142](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/142) 1. Update datainstall dir - * [Pull request 141](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/141) + * [BitBucket pull request 141](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/141) 1. Allow tests to build without automatic linking against project lib - * [Pull request 140](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/140) + * [BitBucket pull request 140](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/140) ### Ignition CMake 2.0.0 (2019-01-31) 1. Require cmake 3.10.2, support `CXX_STANDARD` 17 - * [Pull request 68](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/68) + * [BitBucket pull request 68](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/68) -* [Full list of pull requests]( https://bitbucket.org/ignitionrobotics/ign-cmake/branches/compare/ignition-cmake2_2.0.0%0Dign-cmake1#pull-requests) + * [Full list of changes](https://github.com/ignitionrobotics/ign-cmake/compare/ignition-cmake2_2.0.0...ign-cmake1) ## Ignition CMake 1.x 1. Set viewport for doxygen pages. - * [Pull request 167](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/167) + * [BitBucket pull request 167](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/167) 1. Use upstream `CURL::libcurl` imported target in FindIgnCURL.cmake if available. - * [Pull request 175](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/175) + * [BitBucket pull request 175](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/175) 1. Avoid hardcoding /machine:x64 flag on 64-bit on MSVC. - * [Pull request 171](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/171) - * [Pull request 168](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/168) + * [BitBucket pull request 171](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/171) + * [BitBucket pull request 168](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/168) 1. IgnConfigureBuild: only `add_subdirectory(test)` if `BUILD_TESTING` is ON - * [Pull request 165](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/165) + * [BitBucket pull request 165](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/165) 1. Fix race condition in test for issue 48 - * [Pull request 136](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/136) - * [Issue 48](https://bitbucket.org/ignitionrobotics/ign-cmake/issue/48) + * [BitBucket pull request 136](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/136) + * [Issue 48](https://github.com/ignitionrobotics/ign-cmake/issue/48) 1. Account for inter-component dependencies when importing targets - * [Pull request 131](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/131) - * [Issue 48](https://bitbucket.org/ignitionrobotics/ign-cmake/issue/48) + * [BitBucket pull request 131](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/131) + * [Issue 48](https://github.com/ignitionrobotics/ign-cmake/issue/48) ### Ignition CMake 1.1.0 @@ -109,59 +109,59 @@ ### Ignition CMake 1.0.0 -* [Full list of pull requests](https://bitbucket.org/ignitionrobotics/ign-cmake/branches/compare/ignition-cmake1_1.0.0%0Dign-cmake0#pull-requests) + * [Full list of changes](https://github.com/ignitionrobotics/ign-cmake/compare/ignition-cmake1_1.0.0...ign-cmake0) ## Ignition CMake 0.x 1. Set viewport for doxygen pages. - * [Pull request 167](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/167) + * [BitBucket pull request 167](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/167) 1. Use upstream `CURL::libcurl` imported target in FindIgnCURL.cmake if available. - * [Pull request 175](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/175) + * [BitBucket pull request 175](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/175) 1. Avoid hardcoding /machine:x64 flag on 64-bit on MSVC. - * [Pull request 168](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/168) + * [BitBucket pull request 168](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/168) 1. IgnConfigureBuild: only `add_subdirectory(test)` if `BUILD_TESTING` is ON - * [Pull request 163](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/163) + * [BitBucket pull request 163](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/163) 1. IgnConfigureProject.cmake: fix small typo PKCONFIG -> PKGCONFIG - * [Pull request 118](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/118) + * [BitBucket pull request 118](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/118) ### Ignition CMake 0.6.1 1. Fix duplicated imported target error - * [Pull request 110](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/110) - * [Issue 47](https://bitbucket.org/ignitionrobotics/ign-cmake/issue/47) + * [BitBucket pull request 110](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/110) + * [Issue 47](https://github.com/ignitionrobotics/ign-cmake/issue/47) ### Ignition CMake 0.6.0 1. Properly mark internal CMake cache variables as advanced - * [Pull request 68](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/68) + * [BitBucket pull request 68](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/68) 1. Make line coverage by default, add separate coverage-branch target - * [Pull request 66](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/66) + * [BitBucket pull request 66](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/66) 1. Refactor variable names in example test junit templates - * [Pull request 57](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/57) + * [BitBucket pull request 57](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/57) 1. Suport for `CMAKE_BUILD_TYPE` None - * [Pull request 54](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/54) + * [BitBucket pull request 54](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/54) ### Ignition CMake 0.5.0 1. FindJSONCPP: fix target when pkg-config is successful - * [Pull request 50](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/50) + * [BitBucket pull request 50](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/50) 1. Add branch coverage - * [Pull request 46](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/46) + * [BitBucket pull request 46](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/46) 1. Add FindOptiX.cmake - * [Pull request 34](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests/34) + * [BitBucket pull request 34](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-cmake/pull-requests/34) ### Ignition CMake 0.4.1 -* [Full list of pull requests](https://bitbucket.org/ignitionrobotics/ign-cmake/branches/compare/ignition-cmake_0.4.1%0Dignition-cmake_0.4.0#pull-requests) + * [Full list of changes](https://github.com/ignitionrobotics/ign-cmake/compare/ignition-cmake_0.4.1...ignition-cmake_0.4.0) ### Ignition CMake 0.4.0 diff --git a/README.md b/README.md index ec3a2097..38232366 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ **Maintainer:** grey AT openrobotics.org -[![Bitbucket open issues](https://img.shields.io/bitbucket/issues-raw/ignitionrobotics/ign-cmake.svg)](https://bitbucket.org/ignitionrobotics/ign-cmake/issues) -[![Bitbucket open pull requests](https://img.shields.io/bitbucket/pr-raw/ignitionrobotics/ign-cmake.svg)](https://bitbucket.org/ignitionrobotics/ign-cmake/pull-requests) +[![GitHub open issues](https://img.shields.io/github/issues-raw/ignitionrobotics/ign-cmake.svg)](https://github.com/ignitionrobotics/ign-cmake/issues) +[![GitHub open pull requests](https://img.shields.io/github/issues-pr-raw/ignitionrobotics/ign-cmake.svg)](https://github.com/ignitionrobotics/ign-cmake/pulls) [![Discourse topics](https://img.shields.io/discourse/https/community.gazebosim.org/topics.svg)](https://community.gazebosim.org) [![Hex.pm](https://img.shields.io/hexpm/l/plug.svg)](https://www.apache.org/licenses/LICENSE-2.0) @@ -16,33 +16,33 @@ Windows | [![Build Status](https://build.osrfoundation.org/buildStatus/ico # Table of Contents -[Features](#markdown-header-features) +[Features](#features) -[Install](#markdown-header-install) +[Install](#install) -* [Binary Install](#markdown-header-binary-install) +* [Binary Install](#binary-install) -* [Source Install](#markdown-header-source-install) +* [Source Install](#source-install) - * [Prerequisites](#markdown-header-prerequisites) + * [Prerequisites](#prerequisites) - * [Building from Source](#markdown-header-building-from-source) + * [Building from Source](#building-from-source) -[Usage](#markdown-header-usage) +[Usage](#usage) -[Documentation](#markdown-header-documentation) +[Documentation](#documentation) -[Testing](#markdown-header-testing) +[Testing](#testing) -[Folder Structure](#markdown-header-folder-structure) +[Folder Structure](#folder-structure) -[Code of Conduct](#markdown-header-code-of-conduct) +[Code of Conduct](#code-of-conduct) -[Contributing](#markdown-header-code-of-contributing) +[Contributing](#code-of-contributing) -[Versioning](#markdown-header-versioning) +[Versioning](#versioning) -[License](#markdown-header-license) +[License](#license) # Features @@ -52,9 +52,9 @@ These modules are tailored to the ignition projects, so their use for non-igniti # Install -We recommend following the [Binary Install](#markdown-header-binary-install) instructions to get up and running as quickly and painlessly as possible. +We recommend following the [Binary Install](#binary-install) instructions to get up and running as quickly and painlessly as possible. -The [Source Install](#markdown-header-source-install) instructions should be used if you need the very latest software improvements, you need to modify the code, or you plan to make a contribution. +The [Source Install](#source-install) instructions should be used if you need the very latest software improvements, you need to modify the code, or you plan to make a contribution. ## Binary Install @@ -81,7 +81,7 @@ $ sudo apt install cmake To build and install from source, you can clone the repo and use cmake to install the modules as though this is a regular cmake project: ``` -$ hg clone https://bitbucket.org/ignitionrobotics/ign-cmake +$ git clone https://github.com/ignitionrobotics/ign-cmake $ cd ign-cmake $ mkdir build $ cd build @@ -98,7 +98,7 @@ This library is used internally by the ignition projects. See other ignition pro # Documentation -Documentation for `ignition-cmake` can be found within the source code, and also in the [MIGRATION.md guide](https://bitbucket.org/ignitionrobotics/ign-cmake/src/default/MIGRATION.md). +Documentation for `ignition-cmake` can be found within the source code, and also in the [MIGRATION.md guide](https://github.com/ignitionrobotics/ign-cmake/blob/master/MIGRATION.md). # Testing @@ -122,12 +122,12 @@ $ make test # Contributing Please see -[CONTRIBUTING.md](https://bitbucket.org/ignitionrobotics/ign-gazebo/src/406665896aa40bb42f14cf61d48b3d94f2fc5dd8/CONTRIBUTING.md?at=default&fileviewer=file-view-default). +[CONTRIBUTING.md](https://ignitionrobotics.org/docs/all/contributing). # Code of Conduct Please see -[CODE_OF_CONDUCT.md](https://bitbucket.org/ignitionrobotics/ign-gazebo/src/406665896aa40bb42f14cf61d48b3d94f2fc5dd8/CODE_OF_CONDUCT.md?at=default&fileviewer=file-view-default). +[CODE_OF_CONDUCT.md](https://github.com/ignitionrobotics/ign-gazebo/blob/master/CODE_OF_CONDUCT.md). # Versioning @@ -135,4 +135,4 @@ This library uses [Semantic Versioning](https://semver.org/). Additionally, this # License -This library is licensed under [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0). See also the [LICENSE](https://bitbucket.org/ignitionrobotics/ign-cmake/src/571d06fcbcc530919cbaa6111872b708f5bc0a4b/LICENSE) file. +This library is licensed under [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0). See also the [LICENSE](https://github.com/ignitionrobotics/ign-cmake/blob/master/LICENSE) file. diff --git a/tools/doc_check.sh b/tools/doc_check.sh index 10e01366..d71d225a 100755 --- a/tools/doc_check.sh +++ b/tools/doc_check.sh @@ -4,7 +4,7 @@ # that there are no doxygen warnings. For example, if you're using bitbucket # pipelines then you can add the following line to your bitbucket-pipelines.yml # file: -# - bash <(curl -s https://bitbucket.org/ignitionrobotics/ign-cmake/raw/9db5e5487bc4b979b2f602d0b43b7074e010a0c8/tools/doc_check.sh) +# - bash <(curl -s https://github.com/ignitionrobotics/ign-cmake/raw/master/tools/doc_check.sh) if [ -f ignition-doxygen.warn ]; then if [ -s ignition-doxygen.warn ]; then echo "Error. The following warnings were found in ignition-doxygen.warn." From 8e5305e8841dd863cb519ec8ec2c5e7cd2fd3ea5 Mon Sep 17 00:00:00 2001 From: Grey Date: Tue, 28 Apr 2020 12:57:26 +0800 Subject: [PATCH 21/69] Add codeowner (#82) Signed-off-by: Michael X. Grey --- .github/CODEOWNERS | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000..ee6e8a64 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,4 @@ +# More info: +# https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners + +* @mxgrey From 2d1b1b3d9184165ad1a820606741193a04e8ec81 Mon Sep 17 00:00:00 2001 From: Louise Poubel Date: Mon, 27 Apr 2020 22:25:46 -0700 Subject: [PATCH 22/69] PR collection labeler Signed-off-by: Louise Poubel --- .github/workflows/pr-collection-labeler.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .github/workflows/pr-collection-labeler.yml diff --git a/.github/workflows/pr-collection-labeler.yml b/.github/workflows/pr-collection-labeler.yml new file mode 100644 index 00000000..99e9730b --- /dev/null +++ b/.github/workflows/pr-collection-labeler.yml @@ -0,0 +1,13 @@ +name: PR Collection Labeler + +on: pull_request + +jobs: + pr_collection_labeler: + runs-on: ubuntu-latest + steps: + - name: Add collection labels + if: github.event.action == 'opened' + uses: ignition-tooling/pr-collection-labeler@v1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} From 2f5c3178dbee496beedf8e4a636a2c71219fe8e0 Mon Sep 17 00:00:00 2001 From: Silvio Traversaro Date: Thu, 30 Apr 2020 06:24:44 +0200 Subject: [PATCH 23/69] Fix use of FindYAML.cmake and FindJSONCPP without pkg-config (#79) * Fix use of FindYAML.cmake without pkg-config Signed-off-by: Silvio Traversaro * FindJSONCPP: Fix use without pkg-config if no CMake config is present Signed-off-by: Silvio Traversaro Co-authored-by: Steven Peters --- cmake/FindJSONCPP.cmake | 11 +++++------ cmake/FindYAML.cmake | 12 ++++++------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/cmake/FindJSONCPP.cmake b/cmake/FindJSONCPP.cmake index e1339d19..7f5c78d9 100644 --- a/cmake/FindJSONCPP.cmake +++ b/cmake/FindJSONCPP.cmake @@ -38,7 +38,7 @@ else() if(JSONCPP_FOUND) ign_pkg_config_entry(JSONCPP jsoncpp) else() - ign_pkg_check_modules(JSONCPP jsoncpp) + ign_pkg_check_modules_quiet(JSONCPP jsoncpp) set(JSONCPP_TARGET JSONCPP::JSONCPP) # If that failed, then fall back to manual detection. @@ -70,11 +70,10 @@ else() include(IgnImportTarget) ign_import_target(JSONCPP) endif() - - include(FindPackageHandleStandardArgs) - find_package_handle_standard_args( - JSONCPP - REQUIRED_VARS JSONCPP_FOUND) endif() + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args( + JSONCPP + REQUIRED_VARS JSONCPP_FOUND) endif() endif() diff --git a/cmake/FindYAML.cmake b/cmake/FindYAML.cmake index ba88de2a..f081d1af 100644 --- a/cmake/FindYAML.cmake +++ b/cmake/FindYAML.cmake @@ -52,7 +52,7 @@ if(YAML_FIND_VERSION AND NOT YAML_FIND_VERSION VERSION_EQUAL "0.1") "but you requested version ${YAML_FIND_VERSION}.") else() include(IgnPkgConfig) - ign_pkg_check_modules(YAML yaml-0.1) + ign_pkg_check_modules_quiet(YAML yaml-0.1) # If that failed, then fall back to manual detection. if(NOT YAML_FOUND) @@ -87,10 +87,10 @@ else() INTERFACE_COMPILE_DEFINITIONS "YAML_DECLARE_STATIC" ) endif() - - include(FindPackageHandleStandardArgs) - find_package_handle_standard_args( - YAML - REQUIRED_VARS YAML_FOUND) endif() + + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args( + YAML + REQUIRED_VARS YAML_FOUND) endif() From 4b4d394771e58d2b0c9989bb3af76fecdb3ab887 Mon Sep 17 00:00:00 2001 From: chapulina Date: Mon, 4 May 2020 07:20:32 -0700 Subject: [PATCH 24/69] [ign-cmake2] Workflow updates (#91) Signed-off-by: Louise Poubel --- .github/workflows/ci-bionic.yml | 17 +++++++++++++++++ .github/workflows/triage.yml | 19 +++++++++++++++++++ README.md | 8 ++++---- 3 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/ci-bionic.yml create mode 100644 .github/workflows/triage.yml diff --git a/.github/workflows/ci-bionic.yml b/.github/workflows/ci-bionic.yml new file mode 100644 index 00000000..3f946408 --- /dev/null +++ b/.github/workflows/ci-bionic.yml @@ -0,0 +1,17 @@ +name: Ubuntu Bionic CI + +on: [push, pull_request] + +jobs: + bionic-ci: + runs-on: ubuntu-latest + name: Ubuntu Bionic CI + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Bionic CI + id: ci + uses: ignition-tooling/ubuntu-bionic-ci-action@master + with: + apt-dependencies: 'pkg-config' + codecov-token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/triage.yml b/.github/workflows/triage.yml new file mode 100644 index 00000000..69c16ac8 --- /dev/null +++ b/.github/workflows/triage.yml @@ -0,0 +1,19 @@ +on: + issues: + types: [opened] + pull_request: + types: [opened] +name: Ticket opened +jobs: + assign: + name: Add ticket to inbox + runs-on: ubuntu-latest + steps: + - name: Add ticket to inbox + uses: technote-space/create-project-card-action@v1 + with: + PROJECT: Core development + COLUMN: Inbox + GITHUB_TOKEN: ${{ secrets.TRIAGE_TOKEN }} + CHECK_ORG_PROJECT: true + diff --git a/README.md b/README.md index 38232366..7867bdeb 100644 --- a/README.md +++ b/README.md @@ -9,10 +9,10 @@ Build | Status -- | -- -Test coverage | [![codecov](https://codecov.io/bb/ignitionrobotics/ign-cmake/branch/default/graph/badge.svg)](https://codecov.io/bb/ignitionrobotics/ign-cmake) -Ubuntu Bionic | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=ignition_cmake-ci-default-bionic-amd64)](https://build.osrfoundation.org/job/ignition_cmake-ci-default-bionic-amd64) -Homebrew | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=ignition_cmake-ci-default-homebrew-amd64)](https://build.osrfoundation.org/job/ignition_cmake-ci-default-homebrew-amd64) -Windows | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=ignition_cmake-ci-default-windows7-amd64)](https://build.osrfoundation.org/job/ignition_cmake-ci-default-windows7-amd64) +Test coverage | [![codecov](https://codecov.io/gh/ignitionrobotics/ign-cmake/branch/master/graph/badge.svg)](https://codecov.io/gh/ignitionrobotics/ign-cmake) +Ubuntu Bionic | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=ignition_cmake-ci-master-bionic-amd64)](https://build.osrfoundation.org/job/ignition_cmake-ci-master-bionic-amd64) +Homebrew | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=ignition_cmake-ci-master-homebrew-amd64)](https://build.osrfoundation.org/job/ignition_cmake-ci-master-homebrew-amd64) +Windows | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=ignition_cmake-ci-master-windows7-amd64)](https://build.osrfoundation.org/job/ignition_cmake-ci-master-windows7-amd64) # Table of Contents From f0336126f9e56a3a77c105623fcd74646cbbbf58 Mon Sep 17 00:00:00 2001 From: Silvio Traversaro Date: Mon, 11 May 2020 19:42:55 +0200 Subject: [PATCH 25/69] Fix use of FindIgnOGRE2 on Windows if OGRE2 is not found (#94) If a library is not found, a Find.cmake should fail by setting _FOUND to FALSE, not make the CMake configuration exit with a fatal error using message(FATAL_ERROR ...). Signed-off-by: Silvio Traversaro --- cmake/FindIgnOGRE2.cmake | 4 ---- 1 file changed, 4 deletions(-) diff --git a/cmake/FindIgnOGRE2.cmake b/cmake/FindIgnOGRE2.cmake index 4c4df37f..d48a2f80 100644 --- a/cmake/FindIgnOGRE2.cmake +++ b/cmake/FindIgnOGRE2.cmake @@ -56,8 +56,6 @@ endif() macro(append_library VAR LIB) if(EXISTS "${LIB}") list(APPEND ${VAR} ${LIB}) - else() - message(FATAL_ERROR "Library does not exist: ${LIB}") endif() endmacro() @@ -88,8 +86,6 @@ macro(select_lib_by_build_type LIBRARY_STR OUTPUT_VAR) set(${OUTPUT_VAR} "${LIB_DEBUG}") elseif(LIB_RELEASE) set(${OUTPUT_VAR} "${LIB_RELEASE}") - else() - message(FATAL_ERROR "Can not find libraries in ${LIBRARY_STR}") endif() endmacro() From 961254e848981f4a1e7303570e3308e041a0effb Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Fri, 5 Jun 2020 11:09:30 -0500 Subject: [PATCH 26/69] Disable long-running buildsystem tests by default (#97) (#100) Co-authored-by: Louise Poubel Co-authored-by: Steve Peters Signed-off-by: Michael Carroll --- .github/workflows/ci-bionic.yml | 1 + CMakeLists.txt | 6 ++++++ Changelog.md | 5 +++++ README.md | 2 ++ 4 files changed, 14 insertions(+) diff --git a/.github/workflows/ci-bionic.yml b/.github/workflows/ci-bionic.yml index 3f946408..19cc0848 100644 --- a/.github/workflows/ci-bionic.yml +++ b/.github/workflows/ci-bionic.yml @@ -14,4 +14,5 @@ jobs: uses: ignition-tooling/ubuntu-bionic-ci-action@master with: apt-dependencies: 'pkg-config' + cmake-args: '-DBUILDSYSTEM_TESTING=True' codecov-token: ${{ secrets.CODECOV_TOKEN }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 9039bb84..f65afd9a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,10 @@ include(IgnCMake) # Set up the project ign_configure_project() +#-------------------------------------- +# Set project-specific options +option(BUILDSYSTEM_TESTING "Enable extended buildsystem testing" FALSE) + #-------------------------------------- # Install the ignition documentation files # Note: This is not actually creating a doc target for ign-cmake; this is just @@ -148,7 +152,9 @@ message(STATUS "Install prefix: ${CMAKE_INSTALL_PREFIX}") include(CTest) if (BUILD_TESTING) add_subdirectory(test) +endif() +if (BUILD_TESTING AND BUILDSYSTEM_TESTING) #============================================================================ # Build examples #============================================================================ diff --git a/Changelog.md b/Changelog.md index 23525a83..160953a7 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,10 @@ ## Ignition CMake 2.x +### Ignition CMake 2.2.x + +1. Disable long-running buildsystem tests by default. + * [Pull request 97](https://github.com/ignitionrobotics/ign-cmake/pull/97) + ### Ignition CMake 2.2.0 1. Fix use of FindZIP without pkg-config. diff --git a/README.md b/README.md index 7867bdeb..ed1c6c97 100644 --- a/README.md +++ b/README.md @@ -102,9 +102,11 @@ Documentation for `ignition-cmake` can be found within the source code, and also # Testing +A fuller suite of tests in the `examples` directory can be enabled by building with `BUILDSYSTEM_TESTING` enabled. Tests can be run by building the `test` target. From your build directory you can run: ``` +$ cmake .. -DBUILDSYSTEM_TESTING=1 $ make test ``` From b3116af47bcf480df7a2d16f6d90b079fd9107d4 Mon Sep 17 00:00:00 2001 From: Silvio Traversaro Date: Fri, 12 Jun 2020 03:47:25 +0200 Subject: [PATCH 27/69] Add support for finding several dependencies without pkg-config (#95) * Add ignition_manual_search CMake macro This macro is useful for manually find a C/C++ library, and it is typically used as a fallback if a library is not found with pkg-config. * FindUUID: Support finding the library without pkg-config * Support for finding ffmpeg libraries without pkg-config Signed-off-by: Silvio Traversaro --- cmake/FindAVCODEC.cmake | 14 +++++- cmake/FindAVDEVICE.cmake | 34 +++++++++++++- cmake/FindAVFORMAT.cmake | 14 +++++- cmake/FindAVUTIL.cmake | 14 +++++- cmake/FindSWSCALE.cmake | 14 +++++- cmake/FindUUID.cmake | 14 +++++- cmake/IgnManualSearch.cmake | 94 +++++++++++++++++++++++++++++++++++++ 7 files changed, 192 insertions(+), 6 deletions(-) create mode 100644 cmake/IgnManualSearch.cmake diff --git a/cmake/FindAVCODEC.cmake b/cmake/FindAVCODEC.cmake index b7c820d4..b99043bb 100644 --- a/cmake/FindAVCODEC.cmake +++ b/cmake/FindAVCODEC.cmake @@ -16,4 +16,16 @@ ######################################## # Find avcodec include(IgnPkgConfig) -ign_pkg_check_modules(AVCODEC libavcodec) +ign_pkg_check_modules_quiet(AVCODEC libavcodec) + +if(NOT AVCODEC_FOUND) + include(IgnManualSearch) + ign_manual_search(AVCODEC + HEADER_NAMES "libavcodec/avcodec.h" + LIBRARY_NAMES "avcodec") +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + AVCODEC + REQUIRED_VARS AVCODEC_FOUND) diff --git a/cmake/FindAVDEVICE.cmake b/cmake/FindAVDEVICE.cmake index f8b809d6..c681bf2b 100644 --- a/cmake/FindAVDEVICE.cmake +++ b/cmake/FindAVDEVICE.cmake @@ -20,4 +20,36 @@ set(av_minor ${AVDEVICE_FIND_VERSION_MINOR}) set(av_patch ${AVDEVICE_FIND_VERSION_PATCH}) include(IgnPkgConfig) -ign_pkg_check_modules(AVDEVICE "libavdevice >= ${av_major}.${av_minor}.${av_patch}") +ign_pkg_check_modules_quiet(AVDEVICE "libavdevice >= ${av_major}.${av_minor}.${av_patch}") + +if(NOT AVDEVICE_FOUND) + include(IgnManualSearch) + ign_manual_search(AVDEVICE + HEADER_NAMES "libavdevice/avdevice.h" + LIBRARY_NAMES "avdevice") + + # Version check + if(AVDEVICE_FOUND) + file(READ "${AVDEVICE_INCLUDE_DIRS}/libavdevice/version.h" ver_file) + + string(REGEX MATCH "LIBAVDEVICE_VERSION_MAJOR[ \t\r\n]+([0-9]*)" _ ${ver_file}) + set(ver_major ${CMAKE_MATCH_1}) + + string(REGEX MATCH "LIBAVDEVICE_VERSION_MINOR[ \t\r\n]+([0-9]*)" _ ${ver_file}) + set(ver_minor ${CMAKE_MATCH_1}) + + string(REGEX MATCH "LIBAVDEVICE_VERSION_MICRO[ \t\r\n]+([0-9]*)" _ ${ver_file}) + set(ver_patch ${CMAKE_MATCH_1}) + + set(AVDEVICE_VERSION "${ver_major}.${ver_minor}.${ver_patch}") + + if(AVDEVICE_VERSION VERSION_LESS AVDEVICE_FIND_VERSION) + set(AVDEVICE_FOUND FALSE) + endif() + endif() +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + AVDEVICE + REQUIRED_VARS AVDEVICE_FOUND) \ No newline at end of file diff --git a/cmake/FindAVFORMAT.cmake b/cmake/FindAVFORMAT.cmake index cdde0c5e..5f253873 100644 --- a/cmake/FindAVFORMAT.cmake +++ b/cmake/FindAVFORMAT.cmake @@ -16,4 +16,16 @@ ######################################## # Find AV format include(IgnPkgConfig) -ign_pkg_check_modules(AVFORMAT libavformat) +ign_pkg_check_modules_quiet(AVFORMAT libavformat) + +if(NOT AVFORMAT_FOUND) + include(IgnManualSearch) + ign_manual_search(AVFORMAT + HEADER_NAMES "libavformat/avformat.h" + LIBRARY_NAMES "avformat") +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + AVFORMAT + REQUIRED_VARS AVFORMAT_FOUND) \ No newline at end of file diff --git a/cmake/FindAVUTIL.cmake b/cmake/FindAVUTIL.cmake index 205ffa6b..0bf8e6a5 100644 --- a/cmake/FindAVUTIL.cmake +++ b/cmake/FindAVUTIL.cmake @@ -16,4 +16,16 @@ ######################################## # Find avutil include(IgnPkgConfig) -ign_pkg_check_modules(AVUTIL libavutil) +ign_pkg_check_modules_quiet(AVUTIL libavutil) + +if(NOT AVUTIL_FOUND) + include(IgnManualSearch) + ign_manual_search(AVUTIL + HEADER_NAMES "libavutil/avutil.h" + LIBRARY_NAMES "avutil") +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + AVUTIL + REQUIRED_VARS AVUTIL_FOUND) diff --git a/cmake/FindSWSCALE.cmake b/cmake/FindSWSCALE.cmake index 88a55b6d..dcb36a9e 100644 --- a/cmake/FindSWSCALE.cmake +++ b/cmake/FindSWSCALE.cmake @@ -16,4 +16,16 @@ ######################################## # Find libswscale format include(IgnPkgConfig) -ign_pkg_check_modules(SWSCALE libswscale) +ign_pkg_check_modules_quiet(SWSCALE libswscale) + +if(NOT SWSCALE_FOUND) + include(IgnManualSearch) + ign_manual_search(SWSCALE + HEADER_NAMES "libswscale/swscale.h" + LIBRARY_NAMES "swscale") +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + SWSCALE + REQUIRED_VARS SWSCALE_FOUND) diff --git a/cmake/FindUUID.cmake b/cmake/FindUUID.cmake index bf055d47..24879dc5 100644 --- a/cmake/FindUUID.cmake +++ b/cmake/FindUUID.cmake @@ -17,5 +17,17 @@ # Find uuid if (UNIX) include(IgnPkgConfig) - ign_pkg_check_modules(UUID uuid) + ign_pkg_check_modules_quiet(UUID uuid) + + if(NOT UUID_FOUND) + include(IgnManualSearch) + ign_manual_search(UUID + HEADER_NAMES "uuid/uuid.h" + LIBRARY_NAMES "uuid libuuid") + endif() + + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args( + UUID + REQUIRED_VARS UUID_FOUND) endif() diff --git a/cmake/IgnManualSearch.cmake b/cmake/IgnManualSearch.cmake new file mode 100644 index 00000000..43a5952b --- /dev/null +++ b/cmake/IgnManualSearch.cmake @@ -0,0 +1,94 @@ +#=============================================================================== +# Copyright (C) 2020 Open Source Robotics Foundation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +######################################## +# ign_manual_search( [INTERFACE] +# [HEADER_NAMES ] +# [LIBRARY_NAMES ] +# [TARGET_NAME ]) +# +# This macro will find a library based on the name of one of its headers, +# and the library name. +# It is used inside Find***.cmake scripts, typicall as fallback for a +# ign_pkg_check_modules_quiet call. +# It will create an imported target for the library +# +# INTERFACE: Optional. Use INTERFACE when the target does not actually provide +# a library that needs to be linked against (e.g. it is a header-only +# library, or the target is just used to specify compiler flags). +# +# HEADER_NAMES: Optional. Explicitly specify the header names to search with find_path. +# Default is .h. +# +# LIBRARY_NAMES: Optional. Explicitly specify the names of the library to search with find_library. +# Default is . +# +# TARGET_NAME: Optional. Explicitly specify the desired imported target name. +# Default is ::. +# +macro(ign_manual_search package) + + #------------------------------------ + # Define the expected arguments + set(options INTERFACE) + set(oneValueArgs "TARGET_NAME") + set(multiValueArgs "HEADER_NAMES" "LIBRARY_NAMES") + + #------------------------------------ + # Parse the arguments + _ign_cmake_parse_arguments(ign_manual_search "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if(ign_manual_search_INTERFACE) + set(_ign_manual_search_interface_option INTERFACE) + else() + set(_ign_manual_search_interface_option) # Intentionally blank + endif() + + if(NOT ign_manual_search_HEADER_NAMES) + set(ign_manual_search_HEADER_NAMES "${package}.h") + endif() + + if(NOT ign_manual_search_LIBRARY_NAMES) + set(ign_manual_search_LIBRARY_NAMES "${package}") + endif() + + if(NOT ign_manual_search_TARGET_NAME) + set(ign_manual_search_TARGET_NAME "${package}::${package}") + endif() + + find_path(${package}_INCLUDE_DIRS + NAMES ${ign_manual_search_HEADER_NAMES}) + find_library(${package}_LIBRARIES + NAMES ${ign_manual_search_LIBRARY_NAMES}) + mark_as_advanced(${package}_INCLUDE_DIRS) + mark_as_advanced(${package}_LIBRARIES) + + set(${package}_FOUND true) + + if(NOT ${package}_INCLUDE_DIRS) + set(${package}_FOUND false) + endif() + + if(NOT ${package}_LIBRARIES) + set(${package}_FOUND false) + endif() + + if(${package}_FOUND) + include(IgnImportTarget) + ign_import_target(${package} ${_ign_pkg_check_modules_interface_option} + TARGET_NAME ${ign_pkg_check_modules_TARGET_NAME}) + endif() + +endmacro() From 56f680f361703d1c9bd16b38f1e2305f0e9a6fcf Mon Sep 17 00:00:00 2001 From: Silvio Traversaro Date: Tue, 14 Jul 2020 01:21:07 +0200 Subject: [PATCH 28/69] FindFreeImage: find vcpkg's FreeImage on *nix (#105) The `freeimage` library installed by vcpkg is called `FreeImage` also on Linux and macOS, so to correctly find it is necessary to find both libraries called `freeimage` and libraries called `FreeImage` also on Linux and macOS. Signed-off-by: Silvio Traversaro --- cmake/FindFreeImage.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/FindFreeImage.cmake b/cmake/FindFreeImage.cmake index 673e09d7..891e7552 100644 --- a/cmake/FindFreeImage.cmake +++ b/cmake/FindFreeImage.cmake @@ -73,7 +73,7 @@ if (NOT WIN32) endif(NOT FreeImage_INCLUDE_DIRS) mark_as_advanced(FreeImage_INCLUDE_DIRS) - find_library(FreeImage_LIBRARIES freeimage) + find_library(FreeImage_LIBRARIES NAMES freeimage FreeImage) if(FreeImage_LIBRARIES) set(FreeImage_FOUND true) else() From 43e0df4bc112ee2fc13f22fedb9f796233afa326 Mon Sep 17 00:00:00 2001 From: Silvio Traversaro Date: Mon, 27 Jul 2020 18:39:12 +0200 Subject: [PATCH 29/69] FindUUID: Export include path as expected by Ignition Libraries (#104) Fix https://github.com/ignitionrobotics/ign-cmake/issues/103 Signed-off-by: Silvio --- cmake/FindUUID.cmake | 32 ++++++++++++++++++++++++++++++-- cmake/IgnManualSearch.cmake | 24 +++++++++++++++--------- 2 files changed, 45 insertions(+), 11 deletions(-) diff --git a/cmake/FindUUID.cmake b/cmake/FindUUID.cmake index 24879dc5..54246ed2 100644 --- a/cmake/FindUUID.cmake +++ b/cmake/FindUUID.cmake @@ -22,8 +22,36 @@ if (UNIX) if(NOT UUID_FOUND) include(IgnManualSearch) ign_manual_search(UUID - HEADER_NAMES "uuid/uuid.h" - LIBRARY_NAMES "uuid libuuid") + HEADER_NAMES "uuid.h" + LIBRARY_NAMES "uuid libuuid" + PATH_SUFFIXES "uuid") + endif() + + # The pkg-config or the manual search will place + # /include/uuid in INTERFACE_INCLUDE_DIRECTORIES, + # but some projects exepect to use /include, so + # we add it as well. + # See https://github.com/ignitionrobotics/ign-cmake/issues/103 + if(TARGET UUID::UUID) + get_property(uuid_include_dirs + TARGET UUID::UUID + PROPERTY INTERFACE_INCLUDE_DIRECTORIES) + + set(uuid_include_dirs_extended ${uuid_include_dirs}) + + foreach(include_dir IN LISTS uuid_include_dirs) + if(include_dir MATCHES "uuid$") + get_filename_component(include_dir_parent ${include_dir} DIRECTORY) + list(APPEND uuid_include_dirs_extended ${include_dir_parent}) + endif() + endforeach() + + list(REMOVE_DUPLICATES uuid_include_dirs_extended) + + set_property( + TARGET UUID::UUID + PROPERTY INTERFACE_INCLUDE_DIRECTORIES + ${uuid_include_dirs_extended}) endif() include(FindPackageHandleStandardArgs) diff --git a/cmake/IgnManualSearch.cmake b/cmake/IgnManualSearch.cmake index 43a5952b..98b16453 100644 --- a/cmake/IgnManualSearch.cmake +++ b/cmake/IgnManualSearch.cmake @@ -17,12 +17,13 @@ # ign_manual_search( [INTERFACE] # [HEADER_NAMES ] # [LIBRARY_NAMES ] -# [TARGET_NAME ]) +# [TARGET_NAME ] +# [PATH_SUFFIXES ]]) # # This macro will find a library based on the name of one of its headers, # and the library name. -# It is used inside Find***.cmake scripts, typicall as fallback for a -# ign_pkg_check_modules_quiet call. +# It is used inside Find***.cmake scripts, typicall as fallback for a +# ign_pkg_check_modules_quiet call. # It will create an imported target for the library # # INTERFACE: Optional. Use INTERFACE when the target does not actually provide @@ -38,13 +39,15 @@ # TARGET_NAME: Optional. Explicitly specify the desired imported target name. # Default is ::. # +# PATH_SUFFIXES: Optional. Parameter forwarded to the find_path and find_library calls. +# macro(ign_manual_search package) #------------------------------------ # Define the expected arguments set(options INTERFACE) set(oneValueArgs "TARGET_NAME") - set(multiValueArgs "HEADER_NAMES" "LIBRARY_NAMES") + set(multiValueArgs "HEADER_NAMES" "LIBRARY_NAMES" "PATH_SUFFIXES") #------------------------------------ # Parse the arguments @@ -59,7 +62,7 @@ macro(ign_manual_search package) if(NOT ign_manual_search_HEADER_NAMES) set(ign_manual_search_HEADER_NAMES "${package}.h") endif() - + if(NOT ign_manual_search_LIBRARY_NAMES) set(ign_manual_search_LIBRARY_NAMES "${package}") endif() @@ -67,14 +70,17 @@ macro(ign_manual_search package) if(NOT ign_manual_search_TARGET_NAME) set(ign_manual_search_TARGET_NAME "${package}::${package}") endif() - + find_path(${package}_INCLUDE_DIRS - NAMES ${ign_manual_search_HEADER_NAMES}) + NAMES ${ign_manual_search_HEADER_NAMES} + PATH_SUFFIXES ${ign_manual_search_PATH_SUFFIXES}) find_library(${package}_LIBRARIES - NAMES ${ign_manual_search_LIBRARY_NAMES}) + NAMES ${ign_manual_search_LIBRARY_NAMES} + PATH_SUFFIXES ${ign_manual_search_PATH_SUFFIXES}) + mark_as_advanced(${package}_INCLUDE_DIRS) mark_as_advanced(${package}_LIBRARIES) - + set(${package}_FOUND true) if(NOT ${package}_INCLUDE_DIRS) From 43f448285921f3994d5e99ffe7d788e4678f364d Mon Sep 17 00:00:00 2001 From: Louise Poubel Date: Tue, 4 Aug 2020 15:03:09 -0700 Subject: [PATCH 30/69] Add Focal CI on actions (#106) Signed-off-by: Louise Poubel --- .github/ci/packages.apt | 1 + .github/workflows/ci-bionic.yml | 18 ------------------ .github/workflows/ci.yml | 30 ++++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 18 deletions(-) create mode 100644 .github/ci/packages.apt delete mode 100644 .github/workflows/ci-bionic.yml create mode 100644 .github/workflows/ci.yml diff --git a/.github/ci/packages.apt b/.github/ci/packages.apt new file mode 100644 index 00000000..6d2c214e --- /dev/null +++ b/.github/ci/packages.apt @@ -0,0 +1 @@ +pkg-config diff --git a/.github/workflows/ci-bionic.yml b/.github/workflows/ci-bionic.yml deleted file mode 100644 index 19cc0848..00000000 --- a/.github/workflows/ci-bionic.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Ubuntu Bionic CI - -on: [push, pull_request] - -jobs: - bionic-ci: - runs-on: ubuntu-latest - name: Ubuntu Bionic CI - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Bionic CI - id: ci - uses: ignition-tooling/ubuntu-bionic-ci-action@master - with: - apt-dependencies: 'pkg-config' - cmake-args: '-DBUILDSYSTEM_TESTING=True' - codecov-token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..cbbdf07e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,30 @@ +name: Ubuntu CI + +on: [push] + +jobs: + bionic-ci: + runs-on: ubuntu-latest + name: Ubuntu Bionic CI + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Compile and test + id: ci + uses: ignition-tooling/action-ignition-ci@master + with: + cmake-args: '-DBUILDSYSTEM_TESTING=True' + codecov-token: ${{ secrets.CODECOV_TOKEN }} + focal-ci: + runs-on: ubuntu-latest + name: Ubuntu Focal CI + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Compile and test + id: ci + uses: ignition-tooling/action-ignition-ci@focal + with: + cmake-args: '-DBUILDSYSTEM_TESTING=True' + codecov-token: ${{ secrets.CODECOV_TOKEN }} + From 7419c27963c173de92e7487a4fc95d35cf253251 Mon Sep 17 00:00:00 2001 From: Jose Luis Rivero Date: Fri, 7 Aug 2020 18:19:40 +0200 Subject: [PATCH 31/69] Add ExtraTestMacros feature (#102) The new file provides macros that help with filtering googletest on some of the platforms. Signed-off-by: Jose Luis Rivero Signed-off-by: Louise Poubel --- include/ignition/utilities/ExtraTestMacros.hh | 47 ++++++++++++++ .../utilities/detail/ExtraTestMacros.hh | 62 +++++++++++++++++++ 2 files changed, 109 insertions(+) create mode 100644 include/ignition/utilities/ExtraTestMacros.hh create mode 100644 include/ignition/utilities/detail/ExtraTestMacros.hh diff --git a/include/ignition/utilities/ExtraTestMacros.hh b/include/ignition/utilities/ExtraTestMacros.hh new file mode 100644 index 00000000..5bd800d1 --- /dev/null +++ b/include/ignition/utilities/ExtraTestMacros.hh @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2020 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef IGNITION_UTILITIES_EXTRATESTMACROS_HH +#define IGNITION_UTILITIES_EXTRATESTMACROS_HH + +#include + +/// \brief Restrict the execution of the test for the Windows platform. +/// The test will be compiled on Windows too but will never be run as +/// part of the test suite. The macro uses the Disabled_ prefix provided +/// by googletest. See +/// https://chromium.googlesource.com/external/github.com/google/googletest/+/HEAD/googletest/docs/advanced.md +#define IGN_UTILS_TEST_DISABLED_ON_WIN32(TestName) \ + DETAIL_IGN_UTILS_TEST_DISABLED_ON_WIN32(TestName) + +/// \brief Restrict the execution of the test for the Mac platform. +/// The test will be compiled on Windows too but will never be run as +/// part of the test suite. The macro uses the Disabled_ prefix provided +/// by googletest. See +/// https://chromium.googlesource.com/external/github.com/google/googletest/+/HEAD/googletest/docs/advanced.md +#define IGN_UTILS_TEST_DISABLED_ON_MAC(TestName) \ + DETAIL_IGN_UTILS_TEST_DISABLED_ON_MAC(TestName) + +/// \brief Restrict the execution of the test to just the Linux platform +/// Other platforms will get the test compiled but it won't be run +/// as part of the test suite execution. +/// The macro uses the Disabled_ prefix provided by googletest. See +/// https://chromium.googlesource.com/external/github.com/google/googletest/+/HEAD/googletest/docs/advanced.md +#define IGN_UTILS_TEST_ENABLED_ONLY_ON_LINUX(TestName) \ + DETAIL_IGN_UTILS_TEST_ENABLED_ONLY_ON_LINUX(TestName) + +#endif diff --git a/include/ignition/utilities/detail/ExtraTestMacros.hh b/include/ignition/utilities/detail/ExtraTestMacros.hh new file mode 100644 index 00000000..e9b780fd --- /dev/null +++ b/include/ignition/utilities/detail/ExtraTestMacros.hh @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2020 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef IGNITION_UTILITIES_DETAIL_EXTRATESTMACROS_HH +#define IGNITION_UTILITIES_DETAIL_EXTRATESTMACROS_HH + +#include + +#define DETAIL_IGN_UTILS_ADD_DISABLED_PREFIX(x) DISABLED_##x + +#if defined _WIN32 + + #define DETAIL_IGN_UTILS_TEST_DISABLED_ON_WIN32(TestName) \ + DETAIL_IGN_UTILS_ADD_DISABLED_PREFIX(TestName) + +#else + + #define DETAIL_IGN_UTILS_TEST_DISABLED_ON_WIN32(TestName) \ + TestName + +#endif + +#if defined __APPLE__ + + #define DETAIL_IGN_UTILS_TEST_DISABLED_ON_MAC(TestName) \ + DETAIL_IGN_UTILS_ADD_DISABLED_PREFIX(TestName) + +#else + + #define DETAIL_IGN_UTILS_TEST_DISABLED_ON_MAC(TestName) \ + TestName + +#endif + +#if defined __linux__ + + #define DETAIL_IGN_UTILS_TEST_ENABLED_ONLY_ON_LINUX(TestName) \ + TestName + +#else + + #define DETAIL_IGN_UTILS_TEST_ENABLED_ONLY_ON_LINUX(TestName) \ + DETAIL_IGN_UTILS_ADD_DISABLED_PREFIX(TestName) + +#endif + + +#endif From 5e3246319f1a051f49fa1d4d3a9b357e5e75987e Mon Sep 17 00:00:00 2001 From: Jose Luis Rivero Date: Fri, 7 Aug 2020 21:43:52 +0200 Subject: [PATCH 32/69] Prepare for version 2.3.0 (#107) --- CMakeLists.txt | 2 +- Changelog.md | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f65afd9a..511691a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) #============================================================================ # Initialize the project #============================================================================ -project(ignition-cmake2 VERSION 2.2.0) +project(ignition-cmake2 VERSION 2.3.0) #-------------------------------------- # Initialize the IGNITION_CMAKE_DIR variable with the location of the cmake diff --git a/Changelog.md b/Changelog.md index 160953a7..16cb4f51 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,10 +1,28 @@ ## Ignition CMake 2.x -### Ignition CMake 2.2.x +### Ignition CMake 2.3.0 (2020-08-07) -1. Disable long-running buildsystem tests by default. +1. New macros to help with filter google-test in some platforms + * [Pull request 102](https://github.com/ignitionrobotics/ign-cmake/pull/102) + +1. Disable long-running buildsystem tests by default * [Pull request 97](https://github.com/ignitionrobotics/ign-cmake/pull/97) +1. Fix use of FindYAML.cmake and FindJSONCPP without pkg-config + * [Pull request 79](https://github.com/ignitionrobotics/ign-cmake/pull/79) + +1. Fix use of FindIgnOGRE2 on Windows if OGRE2 is not found + * [Pull request 94](https://github.com/ignitionrobotics/ign-cmake/pull/94) + * Thanks to Silvio Traversaro + +1. FindUUID: Export include path as expected by Ignition Libraries #104 + * [Pull request 104](https://github.com/ignitionrobotics/ign-cmake/pull/104) + * Thanks to Silvio Traversaro + +1. Make the OGRE plugin path discovery portable + * [Pull request 101](https://github.com/ignitionrobotics/ign-cmake/pull/101) + * Thanks to Sean Yen + ### Ignition CMake 2.2.0 1. Fix use of FindZIP without pkg-config. From 220e990588895e1a1773f2bea68f21c4b288e8f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Hern=C3=A1ndez=20Cordero?= Date: Thu, 13 Aug 2020 23:57:35 +0200 Subject: [PATCH 33/69] Added an option to include generated code in the ign_create_docs funtion (#108) Signed-off-by: ahcorde --- cmake/IgnCreateDocs.cmake | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cmake/IgnCreateDocs.cmake b/cmake/IgnCreateDocs.cmake index e151f6d7..030db1d2 100644 --- a/cmake/IgnCreateDocs.cmake +++ b/cmake/IgnCreateDocs.cmake @@ -24,6 +24,7 @@ ################################################# # ign_create_docs( # [API_MAINPAGE_MD ] +# [AUTOGENERATED_DOC ] # [TUTORIALS_MAINPAGE_MD ] # [TAGFILES ]) # @@ -31,6 +32,7 @@ # # API_MAINPAGE_MD: Optional. Specify a Markdown page to use as the main page # for API documentation. +# AUTOGENERATED_DOC: Optional. Directory with the generated code. # TUTORIALS_MAINPAGE_MD: Optional. Specify a Markdown page to use as the # main page for tutorial documentation. # TAGFILES: Optional. Specify tagfiles for doxygen to use. It should be a list of strings like: @@ -40,7 +42,7 @@ function(ign_create_docs) #------------------------------------ # Define the expected arguments set(options) - set(oneValueArgs API_MAINPAGE_MD TUTORIALS_MAINPAGE_MD) + set(oneValueArgs API_MAINPAGE_MD AUTOGENERATED_DOC TUTORIALS_MAINPAGE_MD) set(multiValueArgs "TAGFILES") #------------------------------------ @@ -107,6 +109,7 @@ function(ign_create_docs) ign_add_manpage_target() set(IGNITION_DOXYGEN_API_MAINPAGE_MD ${ign_create_docs_API_MAINPAGE_MD}) + set(IGNITION_DOXYGEN_AUTOGENERATED_DOC ${ign_create_docs_AUTOGENERATED_DOC}) set(IGNITION_DOXYGEN_TUTORIALS_MAINPAGE_MD ${ign_create_docs_TUTORIALS_MAINPAGE_MD}) @@ -134,7 +137,7 @@ function(ign_create_docs) # about the spaces between input files/directories. If you put each cmake # variable on a separate line to make this `set` command more readable, # then doxygen will not generate the correct/complete output. - set(IGNITION_DOXYGEN_INPUT "${IGNITION_DOXYGEN_API_MAINPAGE_MD} ${IGNITION_DOXYGEN_TUTORIALS_DIR} ${IGNITION_DOXYGEN_TUTORIALS_MAINPAGE_MD} ${ign_doxygen_component_input_dirs}") + set(IGNITION_DOXYGEN_INPUT "${IGNITION_DOXYGEN_API_MAINPAGE_MD} ${IGNITION_DOXYGEN_AUTOGENERATED_DOC} ${IGNITION_DOXYGEN_TUTORIALS_DIR} ${IGNITION_DOXYGEN_TUTORIALS_MAINPAGE_MD} ${ign_doxygen_component_input_dirs}") configure_file(${IGNITION_CMAKE_DOXYGEN_DIR}/api.in ${CMAKE_BINARY_DIR}/api.dox @ONLY) @@ -148,7 +151,7 @@ function(ign_create_docs) set(IGNITION_DOXYGEN_GENHTML "NO") set(IGNITION_DOXYGEN_GENTAGFILE "${CMAKE_BINARY_DIR}/${PROJECT_NAME_LOWER}.tag.xml") - set(IGNITION_DOXYGEN_INPUT "${ign_doxygen_component_input_dirs}") + set(IGNITION_DOXYGEN_INPUT "${ign_doxygen_component_input_dirs} ${IGNITION_DOXYGEN_AUTOGENERATED_DOC}") configure_file(${IGNITION_CMAKE_DOXYGEN_DIR}/api.in ${CMAKE_BINARY_DIR}/api_tagfile.dox @ONLY) From 90627498d6e95fa752ce0457dc483513b6eb41a8 Mon Sep 17 00:00:00 2001 From: Louise Poubel Date: Thu, 20 Aug 2020 17:46:29 -0700 Subject: [PATCH 34/69] Bump to 2.4.0 (#110) Signed-off-by: Louise Poubel --- CMakeLists.txt | 2 +- Changelog.md | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 511691a7..417fc881 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) #============================================================================ # Initialize the project #============================================================================ -project(ignition-cmake2 VERSION 2.3.0) +project(ignition-cmake2 VERSION 2.4.0) #-------------------------------------- # Initialize the IGNITION_CMAKE_DIR variable with the location of the cmake diff --git a/Changelog.md b/Changelog.md index 16cb4f51..de09f320 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,12 @@ ## Ignition CMake 2.x +### Ignition CMake 2.X.X (20XX-XX-XX) + +### Ignition CMake 2.4.0 (2020-08-20) + +1. Added an option to include generated code in the ign_create_docs function + * [Pull request 108](https://github.com/ignitionrobotics/ign-cmake/pull/108) + ### Ignition CMake 2.3.0 (2020-08-07) 1. New macros to help with filter google-test in some platforms From 6fb610a720c231542520c54ce5d90a997484d156 Mon Sep 17 00:00:00 2001 From: Nate Koenig Date: Thu, 3 Sep 2020 12:16:50 -0700 Subject: [PATCH 35/69] Add additional input directories to parse when generating documentation (#111) Signed-off-by: Nate Koenig Signed-off-by: Louise Poubel Co-authored-by: Nate Koenig Co-authored-by: Louise Poubel --- cmake/IgnCreateDocs.cmake | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cmake/IgnCreateDocs.cmake b/cmake/IgnCreateDocs.cmake index 030db1d2..a7d69df0 100644 --- a/cmake/IgnCreateDocs.cmake +++ b/cmake/IgnCreateDocs.cmake @@ -26,6 +26,7 @@ # [API_MAINPAGE_MD ] # [AUTOGENERATED_DOC ] # [TUTORIALS_MAINPAGE_MD ] +# [ADDITIONAL_INPUT_DIRS ] # [TAGFILES ]) # # This function will configure doxygen templates and install them. @@ -35,6 +36,7 @@ # AUTOGENERATED_DOC: Optional. Directory with the generated code. # TUTORIALS_MAINPAGE_MD: Optional. Specify a Markdown page to use as the # main page for tutorial documentation. +# ADDITIONAL_INPUT_DIRS: Optional. Specify additional input directories to parse when generating documentation. # TAGFILES: Optional. Specify tagfiles for doxygen to use. It should be a list of strings like: # "${IGNITION-_DOXYGEN_TAGFILE} = ${IGNITION-_API_URL}" function(ign_create_docs) @@ -43,7 +45,7 @@ function(ign_create_docs) # Define the expected arguments set(options) set(oneValueArgs API_MAINPAGE_MD AUTOGENERATED_DOC TUTORIALS_MAINPAGE_MD) - set(multiValueArgs "TAGFILES") + set(multiValueArgs "TAGFILES" "ADDITIONAL_INPUT_DIRS") #------------------------------------ # Parse the arguments @@ -119,6 +121,12 @@ function(ign_create_docs) ign_string_append(IGNITION_DOXYGEN_TAGFILES "\"${tagfile}\"" DELIM " \\\\\\\\\n ") endforeach() + set(IGNITION_DOXYGEN_ADDITIONAL_INPUT_DIRS " ") + + foreach(dir ${ign_create_docs_ADDITIONAL_INPUT_DIRS}) + ign_string_append(IGNITION_DOXYGEN_ADDITIONAL_INPUT_DIRS "${dir}") + endforeach() + find_package(Doxygen) if (DOXYGEN_FOUND AND EXISTS ${IGNITION_CMAKE_DOXYGEN_DIR}/api.in) @@ -137,7 +145,7 @@ function(ign_create_docs) # about the spaces between input files/directories. If you put each cmake # variable on a separate line to make this `set` command more readable, # then doxygen will not generate the correct/complete output. - set(IGNITION_DOXYGEN_INPUT "${IGNITION_DOXYGEN_API_MAINPAGE_MD} ${IGNITION_DOXYGEN_AUTOGENERATED_DOC} ${IGNITION_DOXYGEN_TUTORIALS_DIR} ${IGNITION_DOXYGEN_TUTORIALS_MAINPAGE_MD} ${ign_doxygen_component_input_dirs}") + set(IGNITION_DOXYGEN_INPUT "${IGNITION_DOXYGEN_API_MAINPAGE_MD} ${IGNITION_DOXYGEN_AUTOGENERATED_DOC} ${IGNITION_DOXYGEN_TUTORIALS_DIR} ${IGNITION_DOXYGEN_TUTORIALS_MAINPAGE_MD} ${ign_doxygen_component_input_dirs} ${IGNITION_DOXYGEN_ADDITIONAL_INPUT_DIRS}") configure_file(${IGNITION_CMAKE_DOXYGEN_DIR}/api.in ${CMAKE_BINARY_DIR}/api.dox @ONLY) From eac0b654a19dc67c580e8ceab494915efc6ab796 Mon Sep 17 00:00:00 2001 From: Louise Poubel Date: Tue, 8 Sep 2020 16:18:08 -0700 Subject: [PATCH 36/69] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20=202.5.0=20(#113)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Louise Poubel --- CMakeLists.txt | 2 +- Changelog.md | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 417fc881..43189aa7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) #============================================================================ # Initialize the project #============================================================================ -project(ignition-cmake2 VERSION 2.4.0) +project(ignition-cmake2 VERSION 2.5.0) #-------------------------------------- # Initialize the IGNITION_CMAKE_DIR variable with the location of the cmake diff --git a/Changelog.md b/Changelog.md index de09f320..7dab7cea 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,11 @@ ### Ignition CMake 2.X.X (20XX-XX-XX) +### Ignition CMake 2.5.0 (2020-09-05) + +1. Add additional input directories to parse when generating documentation + * [Pull request 111](https://github.com/ignitionrobotics/ign-cmake/pull/111) + ### Ignition CMake 2.4.0 (2020-08-20) 1. Added an option to include generated code in the ign_create_docs function From 9f14dca9fcdbdc640f8dcdd4cfcb77fe7616e94d Mon Sep 17 00:00:00 2001 From: Juan Oxoby <49600381+joxoby@users.noreply.github.com> Date: Mon, 28 Sep 2020 09:56:33 -0700 Subject: [PATCH 37/69] find_package fixes for TINYXML2 and ZeroMQ (#112) * Add config search for TINYXML2 * Remove set(ZeroMQ_TARGET libzmq) Co-authored-by: Juan Oxoby Signed-off-by: Juan Oxoby --- cmake/FindTINYXML2.cmake | 16 +++++++++++++--- cmake/FindZeroMQ.cmake | 8 -------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/cmake/FindTINYXML2.cmake b/cmake/FindTINYXML2.cmake index c69b147d..cdfaf61c 100644 --- a/cmake/FindTINYXML2.cmake +++ b/cmake/FindTINYXML2.cmake @@ -14,11 +14,21 @@ # limitations under the License. # ######################################## -# Find tinyxml2. Only debian distributions package tinyxml with a pkg-config. +# Find tinyxml2. + +# Try to find it in Config mode first +find_package(TINYXML2 CONFIG QUIET NAMES tinyxml2) +if(TINYXML2_FOUND) + message(STATUS "Found TINYXML2 via Config file: ${TINYXML2_DIR}") + # Create an "alias" target for tinyxml2::tinyxml2 + add_library(TINYXML2::TINYXML2 INTERFACE IMPORTED) + target_link_libraries(TINYXML2::TINYXML2 INTERFACE tinyxml2::tinyxml2) + return() +endif() +# Use pkg_check_modules if the Config search fails. +# Only debian distributions package tinyxml with a pkg-config. include(IgnPkgConfig) - -# Use pkg_check_modules to start ign_pkg_check_modules_quiet(TINYXML2 tinyxml2) # If that failed, then fall back to manual detection (necessary for MacOS) diff --git a/cmake/FindZeroMQ.cmake b/cmake/FindZeroMQ.cmake index 46389486..d22ab8bf 100644 --- a/cmake/FindZeroMQ.cmake +++ b/cmake/FindZeroMQ.cmake @@ -61,17 +61,9 @@ set(ZeroMQ_TARGET ZeroMQ::ZeroMQ) find_package(ZeroMQ ${ZeroMQ_FIND_VERSION} QUIET CONFIG) if (ZeroMQ_FOUND) - - # ZeroMQ's cmake script imports its own target, so we'll - # overwrite the default with the name of theirs. In the - # future, we should be able to use a target alias instead. - set(ZeroMQ_TARGET libzmq) - # Make sure to fill out the pkg-config information before quitting ign_pkg_config_entry(ZeroMQ "libzmq >= ${ZeroMQ_FIND_VERSION}") - return() - endif() if (UNIX) From dfab7c0fe7c763174395396e7a84b1420c25e9f0 Mon Sep 17 00:00:00 2001 From: Louise Poubel Date: Mon, 19 Oct 2020 11:49:10 -0700 Subject: [PATCH 38/69] Improve fork experience (#118) Signed-off-by: Louise Poubel --- .github/workflows/ci.yml | 3 +-- .github/workflows/pr-collection-labeler.yml | 2 +- .github/workflows/triage.yml | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cbbdf07e..f5bafcb7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,6 @@ name: Ubuntu CI -on: [push] +on: [push, pull_request] jobs: bionic-ci: @@ -26,5 +26,4 @@ jobs: uses: ignition-tooling/action-ignition-ci@focal with: cmake-args: '-DBUILDSYSTEM_TESTING=True' - codecov-token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/pr-collection-labeler.yml b/.github/workflows/pr-collection-labeler.yml index 99e9730b..7d7b4e17 100644 --- a/.github/workflows/pr-collection-labeler.yml +++ b/.github/workflows/pr-collection-labeler.yml @@ -1,6 +1,6 @@ name: PR Collection Labeler -on: pull_request +on: pull_request_target jobs: pr_collection_labeler: diff --git a/.github/workflows/triage.yml b/.github/workflows/triage.yml index 69c16ac8..736670e0 100644 --- a/.github/workflows/triage.yml +++ b/.github/workflows/triage.yml @@ -1,7 +1,7 @@ on: issues: types: [opened] - pull_request: + pull_request_target: types: [opened] name: Ticket opened jobs: From c8a47188f70b223ec4f26e3387321fca7d2ea57f Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Thu, 22 Oct 2020 20:11:31 -0500 Subject: [PATCH 39/69] Revert "find_package fixes for TINYXML2 and ZeroMQ (#112)" (#120) This reverts commit 9f14dca9fcdbdc640f8dcdd4cfcb77fe7616e94d. Signed-off-by: Michael Carroll --- cmake/FindTINYXML2.cmake | 16 +++------------- cmake/FindZeroMQ.cmake | 8 ++++++++ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/cmake/FindTINYXML2.cmake b/cmake/FindTINYXML2.cmake index cdfaf61c..c69b147d 100644 --- a/cmake/FindTINYXML2.cmake +++ b/cmake/FindTINYXML2.cmake @@ -14,21 +14,11 @@ # limitations under the License. # ######################################## -# Find tinyxml2. - -# Try to find it in Config mode first -find_package(TINYXML2 CONFIG QUIET NAMES tinyxml2) -if(TINYXML2_FOUND) - message(STATUS "Found TINYXML2 via Config file: ${TINYXML2_DIR}") - # Create an "alias" target for tinyxml2::tinyxml2 - add_library(TINYXML2::TINYXML2 INTERFACE IMPORTED) - target_link_libraries(TINYXML2::TINYXML2 INTERFACE tinyxml2::tinyxml2) - return() -endif() +# Find tinyxml2. Only debian distributions package tinyxml with a pkg-config. -# Use pkg_check_modules if the Config search fails. -# Only debian distributions package tinyxml with a pkg-config. include(IgnPkgConfig) + +# Use pkg_check_modules to start ign_pkg_check_modules_quiet(TINYXML2 tinyxml2) # If that failed, then fall back to manual detection (necessary for MacOS) diff --git a/cmake/FindZeroMQ.cmake b/cmake/FindZeroMQ.cmake index d22ab8bf..46389486 100644 --- a/cmake/FindZeroMQ.cmake +++ b/cmake/FindZeroMQ.cmake @@ -61,9 +61,17 @@ set(ZeroMQ_TARGET ZeroMQ::ZeroMQ) find_package(ZeroMQ ${ZeroMQ_FIND_VERSION} QUIET CONFIG) if (ZeroMQ_FOUND) + + # ZeroMQ's cmake script imports its own target, so we'll + # overwrite the default with the name of theirs. In the + # future, we should be able to use a target alias instead. + set(ZeroMQ_TARGET libzmq) + # Make sure to fill out the pkg-config information before quitting ign_pkg_config_entry(ZeroMQ "libzmq >= ${ZeroMQ_FIND_VERSION}") + return() + endif() if (UNIX) From a559c57e404b964f6b324e8eb8cbb0626e32b033 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Tue, 10 Nov 2020 17:06:24 -0600 Subject: [PATCH 40/69] Correct CMake Logic and update cpplint to Python3 (#117) * Update cpplint to python3 compatible-version * Find and use Python3 if available * Split targets but maintain codecheck * Add Ignition-specific default filters and suppressions Co-authored-by: Louise Poubel Signed-off-by: Michael Carroll --- cmake/IgnCodeCheck.cmake | 18 +- cmake/IgnPython.cmake | 25 + cmake/IgnUtils.cmake | 3 +- codecheck/cpplint.py | 1245 +++++++++++++++++++++++++++++--------- 4 files changed, 1004 insertions(+), 287 deletions(-) create mode 100644 cmake/IgnPython.cmake diff --git a/cmake/IgnCodeCheck.cmake b/cmake/IgnCodeCheck.cmake index 58b3025e..4968898f 100644 --- a/cmake/IgnCodeCheck.cmake +++ b/cmake/IgnCodeCheck.cmake @@ -1,8 +1,8 @@ # Setup the codecheck target, which will run cppcheck and cppplint. function(ign_setup_target_for_codecheck) + include(IgnPython) find_program(CPPCHECK_PATH cppcheck) - find_program(PYTHON_PATH python) find_program(FIND_PATH find) if(NOT CPPCHECK_PATH) @@ -10,11 +10,6 @@ function(ign_setup_target_for_codecheck) return() endif() - if(NOT PYTHON_PATH) - message(STATUS "python not found! Skipping codecheck setup.") - return() - endif() - if(NOT FIND_PATH) message(STATUS "The program [find] was not found! Skipping codecheck setup.") return() @@ -37,17 +32,20 @@ function(ign_setup_target_for_codecheck) message(STATUS "Adding codecheck target") - # Setup the codecheck target - add_custom_target(codecheck - + add_custom_target(cppcheck # First cppcheck COMMAND ${CPPCHECK_PATH} ${CPPCHECK_BASE} ${CPPCHECK_EXTRA} -I ${CPPCHECK_INCLUDE_DIRS} ${CPPCHECK_RULES} `${CPPCHECK_FIND}` # Second cppcheck COMMAND ${CPPCHECK_PATH} ${CPPCHECK_BASE} --enable=missingInclude `${CPPCHECK_FIND}` + ) + add_custom_target(cpplint # cpplint cppcheck - COMMAND python ${IGNITION_CMAKE_CODECHECK_DIR}/cpplint.py --extensions=cc,hh --quiet `${CPPCHECK_FIND}` + COMMAND ${PYTHON_EXECUTABLE} ${IGNITION_CMAKE_CODECHECK_DIR}/cpplint.py --extensions=cc,hh --quiet `${CPPCHECK_FIND}` ) + add_custom_target(codecheck + DEPENDS cpplint cppcheck + ) endfunction() diff --git a/cmake/IgnPython.cmake b/cmake/IgnPython.cmake new file mode 100644 index 00000000..a98a7ed5 --- /dev/null +++ b/cmake/IgnPython.cmake @@ -0,0 +1,25 @@ +# Copyright 2020 Open Source Robotics Foundation, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Copied from ament/ament_cmake: ament_cmake/ament_cmake_core/cmake/core/python.cmake + +set(PYTHON_VERSION "" CACHE STRING + "Specify specific Python version to use ('major.minor' or 'major')") + +# if not specified otherwise use Python 3 +if(NOT PYTHON_VERSION) + set(PYTHON_VERSION "3") +endif() + +find_package(PythonInterp ${PYTHON_VERSION} REQUIRED) diff --git a/cmake/IgnUtils.cmake b/cmake/IgnUtils.cmake index bc6dbdcb..7fa50221 100644 --- a/cmake/IgnUtils.cmake +++ b/cmake/IgnUtils.cmake @@ -1676,7 +1676,8 @@ macro(ign_build_tests) # Find the Python interpreter for running the # check_test_ran.py script - find_package(PythonInterp QUIET) + + include(IgnPython) # Build all the tests foreach(target_name ${test_list}) diff --git a/codecheck/cpplint.py b/codecheck/cpplint.py index c464a134..1632bed1 100644 --- a/codecheck/cpplint.py +++ b/codecheck/cpplint.py @@ -28,6 +28,9 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# Imported from https://github.com/cpplint/cpplint: +# https://github.com/cpplint/cpplint/blob/0f2319741f3407d8638cdc7c41e4fc9bad217f68/cpplint.py + """Does google-lint on c++ files. The goal of this script is to identify places in the code that *may* @@ -44,24 +47,49 @@ import codecs import copy import getopt +import glob +import itertools import math # for log import os import re import sre_compile import string import sys +import sysconfig import unicodedata +import xml.etree.ElementTree + +# if empty, use defaults +_valid_extensions = set([]) + +__VERSION__ = '1.5.4' + +try: + xrange # Python 2 +except NameError: + # -- pylint: disable=redefined-builtin + xrange = range # Python 3 _USAGE = """ -Syntax: cpplint.py [--verbose=#] [--output=vs7] [--filter=-x,+y,...] +Syntax: cpplint.py [--verbose=#] [--output=emacs|eclipse|vs7|junit|sed|gsed] + [--filter=-x,+y,...] [--counting=total|toplevel|detailed] [--root=subdir] + [--repository=path] [--linelength=digits] [--headers=x,y,...] + [--recursive] + [--exclude=path] + [--extensions=hpp,cpp,...] + [--includeorder=default|standardcfirst] [--quiet] + [--version] [file] ... + Style checker for C/C++ source files. + This is a fork of the Google style checker with minor extensions. + The style guidelines this tries to follow are those in - https://google-styleguide.googlecode.com/svn/trunk/cppguide.xml + https://google.github.io/styleguide/cppguide.html Every problem is given a confidence score from 1-5, with 5 meaning we are certain of the problem, and 1 meaning it could be a legitimate construct. @@ -72,17 +100,27 @@ suppresses errors of all categories on that line. The files passed in will be linted; at least one file must be provided. - Default linted extensions are .cc, .cpp, .cu, .cuh and .h. Change the - extensions with the --extensions flag. + Default linted extensions are %s. + Other file types will be ignored. + Change the extensions with the --extensions flag. Flags: - output=vs7 + output=emacs|eclipse|vs7|junit|sed|gsed By default, the output is formatted to ease emacs parsing. Visual Studio - compatible output (vs7) may also be used. Other formats are unsupported. + compatible output (vs7) may also be used. Further support exists for + eclipse (eclipse), and JUnit (junit). XML parsers such as those used + in Jenkins and Bamboo may also be used. + The sed format outputs sed commands that should fix some of the errors. + Note that this requires gnu sed. If that is installed as gsed on your + system (common e.g. on macOS with homebrew) you can use the gsed output + format. Sed commands are written to stdout, not stderr, so you should be + able to pipe output straight to a shell to run the fixes. verbose=# Specify a number 0-5 to restrict errors to certain verbosity levels. + Errors with lower verbosity levels have lower confidence and are more + likely to be false positives. quiet Don't print anything if no errors are found. @@ -109,17 +147,41 @@ also be printed. If 'detailed' is provided, then a count is provided for each category like 'build/class'. + repository=path + The top level directory of the repository, used to derive the header + guard CPP variable. By default, this is determined by searching for a + path that contains .git, .hg, or .svn. When this flag is specified, the + given path is used instead. This option allows the header guard CPP + variable to remain consistent even if members of a team have different + repository root directories (such as when checking out a subdirectory + with SVN). In addition, users of non-mainstream version control systems + can use this flag to ensure readable header guard CPP variables. + + Examples: + Assuming that Alice checks out ProjectName and Bob checks out + ProjectName/trunk and trunk contains src/chrome/ui/browser.h, then + with no --repository flag, the header guard CPP variable will be: + + Alice => TRUNK_SRC_CHROME_BROWSER_UI_BROWSER_H_ + Bob => SRC_CHROME_BROWSER_UI_BROWSER_H_ + + If Alice uses the --repository=trunk flag and Bob omits the flag or + uses --repository=. then the header guard CPP variable will be: + + Alice => SRC_CHROME_BROWSER_UI_BROWSER_H_ + Bob => SRC_CHROME_BROWSER_UI_BROWSER_H_ + root=subdir The root directory used for deriving header guard CPP variable. - By default, the header guard CPP variable is calculated as the relative - path to the directory that contains .git, .hg, or .svn. When this flag - is specified, the relative path is calculated from the specified - directory. If the specified directory does not exist, this flag is - ignored. + This directory is relative to the top level directory of the repository + which by default is determined by searching for a directory that contains + .git, .hg, or .svn but can also be controlled with the --repository flag. + If the specified directory does not exist, this flag is ignored. Examples: - Assuming that top/src/.git exists (and cwd=top/src), the header guard - CPP variables for top/src/chrome/browser/ui/browser.h are: + Assuming that src is the top level directory of the repository (and + cwd=top/src), the header guard CPP variables for + src/chrome/browser/ui/browser.h are: No flag => CHROME_BROWSER_UI_BROWSER_H_ --root=chrome => BROWSER_UI_BROWSER_H_ @@ -133,17 +195,45 @@ Examples: --linelength=120 + recursive + Search for files to lint recursively. Each directory given in the list + of files to be linted is replaced by all files that descend from that + directory. Files with extensions not in the valid extensions list are + excluded. + + exclude=path + Exclude the given path from the list of files to be linted. Relative + paths are evaluated relative to the current directory and shell globbing + is performed. This flag can be provided multiple times to exclude + multiple files. + + Examples: + --exclude=one.cc + --exclude=src/*.cc + --exclude=src/*.cc --exclude=test/*.cc + extensions=extension,extension,... The allowed file extensions that cpplint will check Examples: - --extensions=hpp,cpp + --extensions=%s + + includeorder=default|standardcfirst + For the build/include_order rule, the default is to blindly assume angle + bracket includes with file extension are c-system-headers (default), + even knowing this will have false classifications. + The default is established at google. + standardcfirst means to instead use an allow-list of known c headers and + treat all others as separate group of "other system headers". The C headers + included are those of the C-standard lib and closely related ones. headers=x,y,... The header extensions that cpplint will treat as .h in checks. Values are automatically added to --extensions list. + (by default, only files with extensions %s will be assumed to be headers) Examples: + --headers=%s --headers=hpp,hxx --headers=hpp @@ -168,7 +258,7 @@ "exclude_files" allows to specify a regular expression to be matched against a file name. If the expression matches, the file is skipped and not run - through liner. + through the linter. "linelength" allows to specify the allowed line length for the project. @@ -183,7 +273,7 @@ Example file: filter=-build/include_order,+build/include_alpha - exclude_files=.*\.cc + exclude_files=.*\\.cc The above example disables build/include_order warning and enables build/include_alpha as well as excludes all .cc from being @@ -206,9 +296,12 @@ 'build/forward_decl', 'build/header_guard', 'build/include', + 'build/include_subdir', 'build/include_alpha', 'build/include_order', 'build/include_what_you_use', + 'build/namespaces_headers', + 'build/namespaces_literals', 'build/namespaces', 'build/printf_format', 'build/storage_class', @@ -264,6 +357,13 @@ 'whitespace/todo', ] +# keywords to use with --outputs which generate stdout for machine processing +_MACHINE_OUTPUTS = [ + 'junit', + 'sed', + 'gsed' +] + # These error categories are no longer enforced by cpplint, but for backwards- # compatibility they may still appear in NOLINT comments. _LEGACY_ERROR_CATEGORIES = [ @@ -275,7 +375,22 @@ # flag. By default all errors are on, so only add here categories that should be # off by default (i.e., categories that must be enabled by the --filter= flags). # All entries here should start with a '-' or '+', as in the --filter= flag. -_DEFAULT_FILTERS = ['-build/include_alpha'] +_DEFAULT_FILTERS = [ + '-build/c++11', + '-build/header_guard', + '-build/include_alpha', + '-build/include_order', + '-build/include_subdir', + '-build/namespaces', + '-readability/namespace', + '-runtime/indentation_namespace', + '-runtime/references', + '-whitespace/blank_line', + '-whitespace/braces', + '-whitespace/indent', + '-whitespace/newline', + '-whitespace/parens', + ] # The default list of categories suppressed for C (not C++) files. _DEFAULT_C_SUPPRESSED_CATEGORIES = [ @@ -440,6 +555,186 @@ 'cwctype', ]) +# C headers +_C_HEADERS = frozenset([ + # System C headers + 'assert.h', + 'complex.h', + 'ctype.h', + 'errno.h', + 'fenv.h', + 'float.h', + 'inttypes.h', + 'iso646.h', + 'limits.h', + 'locale.h', + 'math.h', + 'setjmp.h', + 'signal.h', + 'stdalign.h', + 'stdarg.h', + 'stdatomic.h', + 'stdbool.h', + 'stddef.h', + 'stdint.h', + 'stdio.h', + 'stdlib.h', + 'stdnoreturn.h', + 'string.h', + 'tgmath.h', + 'threads.h', + 'time.h', + 'uchar.h', + 'wchar.h', + 'wctype.h', + # additional POSIX C headers + 'aio.h', + 'arpa/inet.h', + 'cpio.h', + 'dirent.h', + 'dlfcn.h', + 'fcntl.h', + 'fmtmsg.h', + 'fnmatch.h', + 'ftw.h', + 'glob.h', + 'grp.h', + 'iconv.h', + 'langinfo.h', + 'libgen.h', + 'monetary.h', + 'mqueue.h', + 'ndbm.h', + 'net/if.h', + 'netdb.h', + 'netinet/in.h', + 'netinet/tcp.h', + 'nl_types.h', + 'poll.h', + 'pthread.h', + 'pwd.h', + 'regex.h', + 'sched.h', + 'search.h', + 'semaphore.h', + 'setjmp.h', + 'signal.h', + 'spawn.h', + 'strings.h', + 'stropts.h', + 'syslog.h', + 'tar.h', + 'termios.h', + 'trace.h', + 'ulimit.h', + 'unistd.h', + 'utime.h', + 'utmpx.h', + 'wordexp.h', + # additional GNUlib headers + 'a.out.h', + 'aliases.h', + 'alloca.h', + 'ar.h', + 'argp.h', + 'argz.h', + 'byteswap.h', + 'crypt.h', + 'endian.h', + 'envz.h', + 'err.h', + 'error.h', + 'execinfo.h', + 'fpu_control.h', + 'fstab.h', + 'fts.h', + 'getopt.h', + 'gshadow.h', + 'ieee754.h', + 'ifaddrs.h', + 'libintl.h', + 'mcheck.h', + 'mntent.h', + 'obstack.h', + 'paths.h', + 'printf.h', + 'pty.h', + 'resolv.h', + 'shadow.h', + 'sysexits.h', + 'ttyent.h', + # Additional linux glibc headers + 'dlfcn.h', + 'elf.h', + 'features.h', + 'gconv.h', + 'gnu-versions.h', + 'lastlog.h', + 'libio.h', + 'link.h', + 'malloc.h', + 'memory.h', + 'netash/ash.h', + 'netatalk/at.h', + 'netax25/ax25.h', + 'neteconet/ec.h', + 'netipx/ipx.h', + 'netiucv/iucv.h', + 'netpacket/packet.h', + 'netrom/netrom.h', + 'netrose/rose.h', + 'nfs/nfs.h', + 'nl_types.h', + 'nss.h', + 're_comp.h', + 'regexp.h', + 'sched.h', + 'sgtty.h', + 'stab.h', + 'stdc-predef.h', + 'stdio_ext.h', + 'syscall.h', + 'termio.h', + 'thread_db.h', + 'ucontext.h', + 'ustat.h', + 'utmp.h', + 'values.h', + 'wait.h', + 'xlocale.h', + # Hardware specific headers + 'arm_neon.h', + 'emmintrin.h', + 'xmmintin.h', + ]) + +# Folders of C libraries so commonly used in C++, +# that they have parity with standard C libraries. +C_STANDARD_HEADER_FOLDERS = frozenset([ + # standard C library + "sys", + # glibc for linux + "arpa", + "asm-generic", + "bits", + "gnu", + "net", + "netinet", + "protocols", + "rpc", + "rpcsvc", + "scsi", + # linux kernel header + "drm", + "linux", + "misc", + "mtd", + "rdma", + "sound", + "video", + "xen", + ]) + # Type names _TYPES = re.compile( r'^(?:' @@ -463,7 +758,8 @@ r'^(?:[^/]*[A-Z][^/]*\.h|lua\.h|lauxlib\.h|lualib\.h)$') # Pattern for matching FileInfo.BaseName() against test file name -_TEST_FILE_SUFFIX = r'(_test|_unittest|_regtest)$' +_test_suffixes = ['_test', '_regtest', '_unittest'] +_TEST_FILE_SUFFIX = '(' + '|'.join(_test_suffixes) + r')$' # Pattern that matches only complete whitespace, possibly across multiple lines. _EMPTY_CONDITIONAL_BODY_PATTERN = re.compile(r'^\s*$', re.DOTALL) @@ -477,7 +773,7 @@ ] # Replacement macros for CHECK/DCHECK/EXPECT_TRUE/EXPECT_FALSE -_CHECK_REPLACEMENT = dict([(m, {}) for m in _CHECK_MACROS]) +_CHECK_REPLACEMENT = dict([(macro_var, {}) for macro_var in _CHECK_MACROS]) for op, replacement in [('==', 'EQ'), ('!=', 'NE'), ('>=', 'GE'), ('>', 'GT'), @@ -525,9 +821,10 @@ # _IncludeState.CheckNextIncludeOrder(). _C_SYS_HEADER = 1 _CPP_SYS_HEADER = 2 -_LIKELY_MY_HEADER = 3 -_POSSIBLE_MY_HEADER = 4 -_OTHER_HEADER = 5 +_OTHER_SYS_HEADER = 3 +_LIKELY_MY_HEADER = 4 +_POSSIBLE_MY_HEADER = 5 +_OTHER_HEADER = 6 # These constants define the current inline assembly state _NO_ASM = 0 # Outside of inline assembly block @@ -547,6 +844,22 @@ # Match string that indicates we're working on a Linux Kernel file. _SEARCH_KERNEL_FILE = re.compile(r'\b(?:LINT_KERNEL_FILE)') +# Commands for sed to fix the problem +_SED_FIXUPS = { + 'Remove spaces around =': r's/ = /=/', + 'Remove spaces around !=': r's/ != /!=/', + 'Remove space before ( in if (': r's/if (/if(/', + 'Remove space before ( in for (': r's/for (/for(/', + 'Remove space before ( in while (': r's/while (/while(/', + 'Remove space before ( in switch (': r's/switch (/switch(/', + 'Should have a space between // and comment': r's/\/\//\/\/ /', + 'Missing space before {': r's/\([^ ]\){/\1 {/', + 'Tab found, replace by spaces': r's/\t/ /g', + 'Line ends in whitespace. Consider deleting these extra spaces.': r's/\s*$//', + 'You don\'t need a ; after a }': r's/};/}/', + 'Missing space after ,': r's/,\([^ ]\)/, \1/g', +} + _regexp_compile_cache = {} # {str, set(int)}: a map from error categories to sets of linenumbers @@ -558,17 +871,55 @@ _root = None _root_debug = False +# The top level repository directory. If set, _root is calculated relative to +# this directory instead of the directory containing version control artifacts. +# This is set by the --repository flag. +_repository = None + +# Files to exclude from linting. This is set by the --exclude flag. +_excludes = None + +# Whether to supress all PrintInfo messages, UNRELATED to --quiet flag +_quiet = False + # The allowed line length of files. # This is set by --linelength flag. _line_length = 80 -# The allowed extensions for file names -# This is set by --extensions flag. -_valid_extensions = set(['cc', 'h', 'cpp', 'cu', 'cuh']) +# This allows to use different include order rule than default +_include_order = "default" + +try: + unicode +except NameError: + # -- pylint: disable=redefined-builtin + basestring = unicode = str + +try: + long +except NameError: + # -- pylint: disable=redefined-builtin + long = int + +if sys.version_info < (3,): + # -- pylint: disable=no-member + # BINARY_TYPE = str + itervalues = dict.itervalues + iteritems = dict.iteritems +else: + # BINARY_TYPE = bytes + itervalues = dict.values + iteritems = dict.items + +def unicode_escape_decode(x): + if sys.version_info < (3,): + return codecs.unicode_escape_decode(x)[0] + else: + return x # Treat all headers starting with 'h' equally: .h, .hpp, .hxx etc. # This is set by --headers flag. -_hpp_headers = set(['h']) +_hpp_headers = set([]) # {str, bool}: a map from error categories to booleans which indicate if the # category should be suppressed for every line. @@ -577,14 +928,47 @@ def ProcessHppHeadersOption(val): global _hpp_headers try: - _hpp_headers = set(val.split(',')) - # Automatically append to extensions list so it does not have to be set 2 times - _valid_extensions.update(_hpp_headers) + _hpp_headers = {ext.strip() for ext in val.split(',')} except ValueError: - PrintUsage('Header extensions must be comma seperated list.') + PrintUsage('Header extensions must be comma separated list.') + +def ProcessIncludeOrderOption(val): + if val is None or val == "default": + pass + elif val == "standardcfirst": + global _include_order + _include_order = val + else: + PrintUsage('Invalid includeorder value %s. Expected default|standardcfirst') def IsHeaderExtension(file_extension): - return file_extension in _hpp_headers + return file_extension in GetHeaderExtensions() + +def GetHeaderExtensions(): + if _hpp_headers: + return _hpp_headers + if _valid_extensions: + return {h for h in _valid_extensions if 'h' in h} + return set(['h', 'hh', 'hpp', 'hxx', 'h++', 'cuh']) + +# The allowed extensions for file names +# This is set by --extensions flag +def GetAllExtensions(): + return GetHeaderExtensions().union(_valid_extensions or set( + ['c', 'cc', 'cpp', 'cxx', 'c++', 'cu'])) + +def ProcessExtensionsOption(val): + global _valid_extensions + try: + extensions = [ext.strip() for ext in val.split(',')] + _valid_extensions = set(extensions) + except ValueError: + PrintUsage('Extensions should be a comma-separated list of values;' + 'for example: extensions=hpp,cpp\n' + 'This could not be parsed: "%s"' % (val,)) + +def GetNonHeaderExtensions(): + return GetAllExtensions().difference(GetHeaderExtensions()) def ParseNolintSuppressions(filename, raw_line, linenum, error): """Updates the global list of line error-suppressions. @@ -697,7 +1081,7 @@ def Search(pattern, s): def _IsSourceExtension(s): """File extension (excluding dot) matches a source file extension.""" - return s in ('c', 'cc', 'cpp', 'cxx') + return s in GetNonHeaderExtensions() class _IncludeState(object): @@ -718,11 +1102,13 @@ class _IncludeState(object): _MY_H_SECTION = 1 _C_SECTION = 2 _CPP_SECTION = 3 - _OTHER_H_SECTION = 4 + _OTHER_SYS_SECTION = 4 + _OTHER_H_SECTION = 5 _TYPE_NAMES = { _C_SYS_HEADER: 'C system header', _CPP_SYS_HEADER: 'C++ system header', + _OTHER_SYS_HEADER: 'other system header', _LIKELY_MY_HEADER: 'header this file implements', _POSSIBLE_MY_HEADER: 'header this file may implement', _OTHER_HEADER: 'other header', @@ -732,11 +1118,14 @@ class _IncludeState(object): _MY_H_SECTION: 'a header this file implements', _C_SECTION: 'C system header', _CPP_SECTION: 'C++ system header', + _OTHER_SYS_SECTION: 'other system header', _OTHER_H_SECTION: 'other header', } def __init__(self): self.include_list = [[]] + self._section = None + self._last_header = None self.ResetSection('') def FindHeader(self, header): @@ -843,6 +1232,12 @@ def CheckNextIncludeOrder(self, header_type): else: self._last_header = '' return error_message + elif header_type == _OTHER_SYS_HEADER: + if self._section <= self._OTHER_SYS_SECTION: + self._section = self._OTHER_SYS_SECTION + else: + self._last_header = '' + return error_message elif header_type == _LIKELY_MY_HEADER: if self._section <= self._MY_H_SECTION: self._section = self._MY_H_SECTION @@ -881,9 +1276,18 @@ def __init__(self): # output format: # "emacs" - format that emacs can parse (default) + # "eclipse" - format that eclipse can parse # "vs7" - format that Microsoft Visual Studio 7 can parse + # "junit" - format that Jenkins, Bamboo, etc can parse + # "sed" - returns a gnu sed command to fix the problem + # "gsed" - like sed, but names the command gsed, e.g. for macOS homebrew users self.output_format = 'emacs' + # For JUnit output, save errors and failures until the end so that they + # can be written into the XML + self._junit_errors = [] + self._junit_failures = [] + def SetOutputFormat(self, output_format): """Sets the output format for errors.""" self.output_format = output_format @@ -958,10 +1362,71 @@ def IncrementErrorCount(self, category): def PrintErrorCounts(self): """Print a summary of errors by category, and the total.""" - for category, count in self.errors_by_category.iteritems(): - sys.stderr.write('Category \'%s\' errors found: %d\n' % + for category, count in sorted(iteritems(self.errors_by_category)): + self.PrintInfo('Category \'%s\' errors found: %d\n' % (category, count)) - sys.stdout.write('Total errors found: %d\n' % self.error_count) + if self.error_count > 0: + self.PrintInfo('Total errors found: %d\n' % self.error_count) + + def PrintInfo(self, message): + # _quiet does not represent --quiet flag. + # Hide infos from stdout to keep stdout pure for machine consumption + if not _quiet and self.output_format not in _MACHINE_OUTPUTS: + sys.stdout.write(message) + + def PrintError(self, message): + if self.output_format == 'junit': + self._junit_errors.append(message) + else: + sys.stderr.write(message) + + def AddJUnitFailure(self, filename, linenum, message, category, confidence): + self._junit_failures.append((filename, linenum, message, category, + confidence)) + + def FormatJUnitXML(self): + num_errors = len(self._junit_errors) + num_failures = len(self._junit_failures) + + testsuite = xml.etree.ElementTree.Element('testsuite') + testsuite.attrib['errors'] = str(num_errors) + testsuite.attrib['failures'] = str(num_failures) + testsuite.attrib['name'] = 'cpplint' + + if num_errors == 0 and num_failures == 0: + testsuite.attrib['tests'] = str(1) + xml.etree.ElementTree.SubElement(testsuite, 'testcase', name='passed') + + else: + testsuite.attrib['tests'] = str(num_errors + num_failures) + if num_errors > 0: + testcase = xml.etree.ElementTree.SubElement(testsuite, 'testcase') + testcase.attrib['name'] = 'errors' + error = xml.etree.ElementTree.SubElement(testcase, 'error') + error.text = '\n'.join(self._junit_errors) + if num_failures > 0: + # Group failures by file + failed_file_order = [] + failures_by_file = {} + for failure in self._junit_failures: + failed_file = failure[0] + if failed_file not in failed_file_order: + failed_file_order.append(failed_file) + failures_by_file[failed_file] = [] + failures_by_file[failed_file].append(failure) + # Create a testcase for each file + for failed_file in failed_file_order: + failures = failures_by_file[failed_file] + testcase = xml.etree.ElementTree.SubElement(testsuite, 'testcase') + testcase.attrib['name'] = failed_file + failure = xml.etree.ElementTree.SubElement(testcase, 'failure') + template = '{0}: {1} [{2}] [{3}]' + texts = [template.format(f[1], f[2], f[3], f[4]) for f in failures] + failure.text = '\n'.join(texts) + + xml_decl = '\n' + return xml_decl + xml.etree.ElementTree.tostring(testsuite, 'utf-8').decode('utf-8') + _cpplint_state = _CppLintState() @@ -1115,12 +1580,12 @@ def FullName(self): return os.path.abspath(self._filename).replace('\\', '/') def RepositoryName(self): - """FullName after removing the local path to the repository. + r"""FullName after removing the local path to the repository. If we have a real absolute path name here we can try to do something smart: detecting the root of the checkout and truncating /path/to/checkout from the name so that we get header guards that don't include things like - "C:\Documents and Settings\..." or "/home/username/..." in them and thus + "C:\\Documents and Settings\\..." or "/home/username/..." in them and thus people on different computers who have checked the source out to different locations won't see bogus errors. """ @@ -1129,6 +1594,20 @@ def RepositoryName(self): if os.path.exists(fullname): project_dir = os.path.dirname(fullname) + # If the user specified a repository path, it exists, and the file is + # contained in it, use the specified repository path + if _repository: + repo = FileInfo(_repository).FullName() + root_dir = project_dir + while os.path.exists(root_dir): + # allow case insensitive compare on Windows + if os.path.normcase(root_dir) == os.path.normcase(repo): + return os.path.relpath(fullname, root_dir).replace('\\', '/') + one_up_dir = os.path.dirname(root_dir) + if one_up_dir == root_dir: + break + root_dir = one_up_dir + if os.path.exists(os.path.join(project_dir, ".svn")): # If there's a .svn file in the current directory, we recursively look # up the directory tree for the top of the SVN checkout @@ -1179,7 +1658,7 @@ def BaseName(self): return self.Split()[1] def Extension(self): - """File extension - text following the final period.""" + """File extension - text following the final period, includes that period.""" return self.Split()[2] def NoExtension(self): @@ -1244,15 +1723,25 @@ def Error(filename, linenum, category, confidence, message): if _ShouldPrintError(category, confidence, linenum): _cpplint_state.IncrementErrorCount(category) if _cpplint_state.output_format == 'vs7': - sys.stderr.write('%s(%s): error cpplint: [%s] %s [%d]\n' % ( + _cpplint_state.PrintError('%s(%s): error cpplint: [%s] %s [%d]\n' % ( filename, linenum, category, message, confidence)) elif _cpplint_state.output_format == 'eclipse': sys.stderr.write('%s:%s: warning: %s [%s] [%d]\n' % ( filename, linenum, message, category, confidence)) + elif _cpplint_state.output_format == 'junit': + _cpplint_state.AddJUnitFailure(filename, linenum, message, category, + confidence) + elif _cpplint_state.output_format in ['sed', 'gsed']: + if message in _SED_FIXUPS: + sys.stdout.write(_cpplint_state.output_format + " -i '%s%s' %s # %s [%s] [%d]\n" % ( + linenum, _SED_FIXUPS[message], filename, message, category, confidence)) + else: + sys.stderr.write('# %s:%s: "%s" [%s] [%d]\n' % ( + filename, linenum, message, category, confidence)) else: - sys.stderr.write('%s:%s: %s [%s] [%d]\n' % ( - filename, linenum, message, category, confidence)) - + final_message = '%s:%s: %s [%s] [%d]\n' % ( + filename, linenum, message, category, confidence) + sys.stderr.write(final_message) # Matches standard C++ escape sequences per 2.13.2.3 of the C++ standard. _RE_PATTERN_CLEANSE_LINE_ESCAPES = re.compile( @@ -1389,7 +1878,7 @@ def FindNextMultiLineCommentEnd(lines, lineix): def RemoveMultiLineCommentsFromRange(lines, begin, end): """Clears a range of lines for multi-line comments.""" - # Having // dummy comments makes the lines non-empty, so we will not get + # Having // comments makes the lines non-empty, so we will not get # unnecessary blank line warnings later in the code. for i in range(begin, end): lines[i] = '/**/' @@ -1763,7 +2252,7 @@ def CheckForCopyright(filename, lines, error): """Logs an error if no Copyright message appears at the top of the file.""" # We'll say it should occur by line 10. Don't forget there's a - # dummy line at the front. + # placeholder line at the front. for line in xrange(1, min(len(lines), 11)): if re.search(r'Copyright', lines[line], re.I): break else: # means no copyright line was found @@ -1799,10 +2288,10 @@ def PathSplitToList(path): lst = [] while True: (head, tail) = os.path.split(path) - if head == path: # absolute paths end + if head == path: # absolute paths end lst.append(head) break - if tail == path: # relative paths end + if tail == path: # relative paths end lst.append(tail) break @@ -1837,7 +2326,7 @@ def GetHeaderGuardCPPVariable(filename): def FixupPathFromRoot(): if _root_debug: sys.stderr.write("\n_root fixup, _root = '%s', repository name = '%s'\n" - %(_root, fileinfo.RepositoryName())) + % (_root, fileinfo.RepositoryName())) # Process the file path with the --root flag if it was set. if not _root: @@ -1858,28 +2347,29 @@ def StripListPrefix(lst, prefix): PathSplitToList(_root)) if _root_debug: - sys.stderr.write("_root lstrip (maybe_path=%s, file_path_from_root=%s," + - " _root=%s)\n" %(maybe_path, file_path_from_root, _root)) + sys.stderr.write(("_root lstrip (maybe_path=%s, file_path_from_root=%s," + + " _root=%s)\n") % (maybe_path, file_path_from_root, _root)) if maybe_path: return os.path.join(*maybe_path) # --root=.. , will prepend the outer directory to the header guard full_path = fileinfo.FullName() - root_abspath = os.path.abspath(_root) + # adapt slashes for windows + root_abspath = os.path.abspath(_root).replace('\\', '/') maybe_path = StripListPrefix(PathSplitToList(full_path), PathSplitToList(root_abspath)) if _root_debug: - sys.stderr.write("_root prepend (maybe_path=%s, full_path=%s, " + - "root_abspath=%s)\n" %(maybe_path, full_path, root_abspath)) + sys.stderr.write(("_root prepend (maybe_path=%s, full_path=%s, " + + "root_abspath=%s)\n") % (maybe_path, full_path, root_abspath)) if maybe_path: return os.path.join(*maybe_path) if _root_debug: - sys.stderr.write("_root ignore, returning %s\n" %(file_path_from_root)) + sys.stderr.write("_root ignore, returning %s\n" % (file_path_from_root)) # --root=FAKE_DIR is ignored return file_path_from_root @@ -1911,6 +2401,11 @@ def CheckForHeaderGuard(filename, clean_lines, error): if Search(r'//\s*NOLINT\(build/header_guard\)', i): return + # Allow pragma once instead of header guards + for i in raw_lines: + if Search(r'^\s*#pragma\s+once', i): + return + cppvar = GetHeaderGuardCPPVariable(filename) ifndef = '' @@ -1952,63 +2447,71 @@ def CheckForHeaderGuard(filename, clean_lines, error): '#ifndef header guard has wrong style, please use: %s' % cppvar) # Check for "//" comments on endif line. - # ParseNolintSuppressions(filename, raw_lines[endif_linenum], endif_linenum, - # error) - # match = Match(r'#endif\s*//\s*' + cppvar + r'(_)?\b', endif) - # if match: - # if match.group(1) == '_': - # # Issue low severity warning for deprecated double trailing underscore - # error(filename, endif_linenum, 'build/header_guard', 0, - # '#endif line should be "#endif // %s"' % cppvar) - # return + ParseNolintSuppressions(filename, raw_lines[endif_linenum], endif_linenum, + error) + match = Match(r'#endif\s*//\s*' + cppvar + r'(_)?\b', endif) + if match: + if match.group(1) == '_': + # Issue low severity warning for deprecated double trailing underscore + error(filename, endif_linenum, 'build/header_guard', 0, + '#endif line should be "#endif // %s"' % cppvar) + return # Didn't find the corresponding "//" comment. If this file does not # contain any "//" comments at all, it could be that the compiler # only wants "/**/" comments, look for those instead. - # no_single_line_comments = True - # for i in xrange(1, len(raw_lines) - 1): - # line = raw_lines[i] - # if Match(r'^(?:(?:\'(?:\.|[^\'])*\')|(?:"(?:\.|[^"])*")|[^\'"])*//', line): - # no_single_line_comments = False - # break - - # if no_single_line_comments: - # match = Match(r'#endif\s*/\*\s*' + cppvar + r'(_)?\s*\*/', endif) - # if match: - # if match.group(1) == '_': - # # Low severity warning for double trailing underscore - # error(filename, endif_linenum, 'build/header_guard', 0, - # '#endif line should be "#endif /* %s */"' % cppvar) - # return - - # # Didn't find anything - # error(filename, endif_linenum, 'build/header_guard', 5, - # '#endif line should be "#endif // %s"' % cppvar) + no_single_line_comments = True + for i in xrange(1, len(raw_lines) - 1): + line = raw_lines[i] + if Match(r'^(?:(?:\'(?:\.|[^\'])*\')|(?:"(?:\.|[^"])*")|[^\'"])*//', line): + no_single_line_comments = False + break + + if no_single_line_comments: + match = Match(r'#endif\s*/\*\s*' + cppvar + r'(_)?\s*\*/', endif) + if match: + if match.group(1) == '_': + # Low severity warning for double trailing underscore + error(filename, endif_linenum, 'build/header_guard', 0, + '#endif line should be "#endif /* %s */"' % cppvar) + return + + # Didn't find anything + error(filename, endif_linenum, 'build/header_guard', 5, + '#endif line should be "#endif // %s"' % cppvar) def CheckHeaderFileIncluded(filename, include_state, error): - """Logs an error if a .cc file does not include its header.""" + """Logs an error if a source file does not include its header.""" # Do not check test files fileinfo = FileInfo(filename) if Search(_TEST_FILE_SUFFIX, fileinfo.BaseName()): return - headerfile = filename[0:len(filename) - len(fileinfo.Extension())] + '.h' - if not os.path.exists(headerfile): - return - headername = FileInfo(headerfile).RepositoryName() - first_include = 0 - for section_list in include_state.include_list: - for f in section_list: - if headername in f[0] or f[0] in headername: - return - if not first_include: - first_include = f[1] + for ext in GetHeaderExtensions(): + basefilename = filename[0:len(filename) - len(fileinfo.Extension())] + headerfile = basefilename + '.' + ext + if not os.path.exists(headerfile): + continue + headername = FileInfo(headerfile).RepositoryName() + first_include = None + include_uses_unix_dir_aliases = False + for section_list in include_state.include_list: + for f in section_list: + include_text = f[0] + if "./" in include_text: + include_uses_unix_dir_aliases = True + if headername in include_text or include_text in headername: + return + if not first_include: + first_include = f[1] + + message = '%s should include its header file %s' % (fileinfo.RepositoryName(), headername) + if include_uses_unix_dir_aliases: + message += ". Relative paths like . and .. are not allowed." - error(filename, first_include, 'build/include', 5, - '%s should include its header file %s' % (fileinfo.RepositoryName(), - headername)) + error(filename, first_include, 'build/include', 5, message) def CheckForBadCharacters(filename, lines, error): @@ -2029,7 +2532,7 @@ def CheckForBadCharacters(filename, lines, error): error: The function to call with any errors found. """ for linenum, line in enumerate(lines): - if u'\ufffd' in line: + if unicode_escape_decode('\ufffd') in line: error(filename, linenum, 'readability/utf8', 5, 'Line contains invalid UTF-8 (or Unicode replacement character).') if '\0' in line: @@ -2373,20 +2876,26 @@ def CheckEnd(self, filename, clean_lines, linenum, error): # Besides these, we don't accept anything else, otherwise we might # get false negatives when existing comment is a substring of the # expected namespace. - # if self.name: - # return - # else: - # # Anonymous namespace - # if not Match(r'^\s*};*\s*(//|/\*).*\bnamespace[\*/\.\\\s]*$', line): - # # If "// namespace anonymous" or "// anonymous namespace (more text)", - # # mention "// anonymous namespace" as an acceptable form - # if Match(r'^\s*}.*\b(namespace anonymous|anonymous namespace)\b', line): - # error(filename, linenum, 'readability/namespace', 5, - # 'Anonymous namespace should be terminated with "// namespace"' - # ' or "// anonymous namespace"') - # else: - # error(filename, linenum, 'readability/namespace', 5, - # 'Anonymous namespace should be terminated with "// namespace"') + if self.name: + # Named namespace + if not Match((r'^\s*};*\s*(//|/\*).*\bnamespace\s+' + + re.escape(self.name) + r'[\*/\.\\\s]*$'), + line): + error(filename, linenum, 'readability/namespace', 5, + 'Namespace should be terminated with "// namespace %s"' % + self.name) + else: + # Anonymous namespace + if not Match(r'^\s*};*\s*(//|/\*).*\bnamespace[\*/\.\\\s]*$', line): + # If "// namespace anonymous" or "// anonymous namespace (more text)", + # mention "// anonymous namespace" as an acceptable form + if Match(r'^\s*}.*\b(namespace anonymous|anonymous namespace)\b', line): + error(filename, linenum, 'readability/namespace', 5, + 'Anonymous namespace should be terminated with "// namespace"' + ' or "// anonymous namespace"') + else: + error(filename, linenum, 'readability/namespace', 5, + 'Anonymous namespace should be terminated with "// namespace"') class _PreprocessorInfo(object): @@ -2652,8 +3161,8 @@ def Update(self, filename, clean_lines, linenum, error): # class LOCKABLE API Object { # }; class_decl_match = Match( - r'^(\s*(?:template\s*<[\w\s<>,:]*>\s*)?' - r'(class|struct)\s+(?:[A-Z_]+\s+)*(\w+(?:::\w+)*))' + r'^(\s*(?:template\s*<[\w\s<>,:=]*>\s*)?' + r'(class|struct)\s+(?:[a-zA-Z0-9_]+\s+)*(\w+(?:::\w+)*))' r'(.*)$', line) if (class_decl_match and (not self.stack or self.stack[-1].open_parentheses == 0)): @@ -2688,10 +3197,10 @@ def Update(self, filename, clean_lines, linenum, error): if access_match: classinfo.access = access_match.group(2) - # Check that access keywords are indented +2 space. Skip this + # Check that access keywords are indented +1 space. Skip this # check if the keywords are not preceded by whitespaces. indent = access_match.group(1) - if (len(indent) != classinfo.class_indent + 2 and + if (len(indent) != classinfo.class_indent + 1 and Match(r'^\s*$', indent)): if classinfo.is_struct: parent = 'struct ' + classinfo.name @@ -2901,6 +3410,7 @@ def CheckForNonStandardConstructs(filename, clean_lines, linenum, constructor_args[i] = constructor_arg i += 1 + variadic_args = [arg for arg in constructor_args if '&&...' in arg] defaulted_args = [arg for arg in constructor_args if '=' in arg] noarg_constructor = (not constructor_args or # empty arg list # 'void' arg specifier @@ -2911,20 +3421,24 @@ def CheckForNonStandardConstructs(filename, clean_lines, linenum, # all but at most one arg defaulted (len(constructor_args) >= 1 and not noarg_constructor and - len(defaulted_args) >= len(constructor_args) - 1)) + len(defaulted_args) >= len(constructor_args) - 1) or + # variadic arguments with zero or one argument + (len(constructor_args) <= 2 and + len(variadic_args) >= 1)) initializer_list_constructor = bool( onearg_constructor and Search(r'\bstd\s*::\s*initializer_list\b', constructor_args[0])) copy_constructor = bool( onearg_constructor and - Match(r'(const\s+)?%s(\s*<[^>]*>)?(\s+const)?\s*(?:<\w+>\s*)?&' + Match(r'((const\s+(volatile\s+)?)?|(volatile\s+(const\s+)?))?' + r'%s(\s*<[^>]*>)?(\s+const)?\s*(?:<\w+>\s*)?&' % re.escape(base_classname), constructor_args[0].strip())) if (not is_marked_explicit and onearg_constructor and not initializer_list_constructor and not copy_constructor): - if defaulted_args: + if defaulted_args or variadic_args: error(filename, linenum, 'runtime/explicit', 5, 'Constructors callable with one argument ' 'should be marked explicit.') @@ -2998,8 +3512,7 @@ def CheckSpacingForFunctionCall(filename, clean_lines, linenum, error): if Search(r'\boperator_*\b', line): error(filename, linenum, 'whitespace/parens', 0, 'Extra space before ( in function call') - # If < and > are present, then we assume fncall is a function pointer. - elif not Search(r'\<.*\>', fncall): + else: error(filename, linenum, 'whitespace/parens', 4, 'Extra space before ( in function call') # If the ) is followed only by a newline or a { + newline, assume it's @@ -3090,7 +3603,7 @@ def CheckForFunctionLengths(filename, clean_lines, linenum, if Search(r'(;|})', start_line): # Declarations and trivial functions body_found = True break # ... ignore - elif Search(r'{', start_line): + if Search(r'{', start_line): body_found = True function = Search(r'((\w|:)*)\(', line).group(1) if Match(r'TEST', function): # Handle TEST... macros @@ -3269,9 +3782,9 @@ def CheckSpacing(filename, clean_lines, linenum, nesting_state, error): 'should be deleted.') matched = Match(r'\s*(public|protected|private):', prev_line) - # if matched: - # error(filename, linenum, 'whitespace/blank_line', 3, - # 'Do not leave a blank line after "%s:"' % matched.group(1)) + if matched: + error(filename, linenum, 'whitespace/blank_line', 3, + 'Do not leave a blank line after "%s:"' % matched.group(1)) # Next, check comments next_line_start = 0 @@ -3283,9 +3796,10 @@ def CheckSpacing(filename, clean_lines, linenum, nesting_state, error): # get rid of comments and strings line = clean_lines.elided[linenum] - # You shouldn't have spaces before your brackets, except maybe after - # 'delete []' or 'return []() {};' - if Search(r'\w\s+\[', line) and not Search(r'(?:delete|return)\s+\[', line): + # You shouldn't have spaces before your brackets, except for C++11 attributes + # or maybe after 'delete []', 'return []() {};', or 'auto [abc, ...] = ...;'. + if (Search(r'\w\s+\[(?!\[)', line) and + not Search(r'(?:auto&?|delete|return)\s+\[', line)): error(filename, linenum, 'whitespace/braces', 5, 'Extra space before [') @@ -3655,7 +4169,6 @@ def IsDecltype(clean_lines, linenum, column): return True return False - def CheckSectionSpacing(filename, clean_lines, class_info, linenum, error): """Checks for additional blank line issues related to sections. @@ -3757,16 +4270,18 @@ def CheckBraces(filename, clean_lines, linenum, error): # following line if it is part of an array initialization and would not fit # within the 80 character limit of the preceding line. prevline = GetPreviousNonBlankLine(clean_lines, linenum)[0] - # if (not Search(r'[,;:}{(]\s*$', prevline) and - # not Match(r'\s*#', prevline) and - # not (GetLineWidth(prevline) > _line_length - 2 and '[]' in prevline)): - # error(filename, linenum, 'whitespace/braces', 4, - # '{ should almost always be at the end of the previous line') + if (not Search(r'[,;:}{(]\s*$', prevline) and + not Match(r'\s*#', prevline) and + not (GetLineWidth(prevline) > _line_length - 2 and '[]' in prevline)): + error(filename, linenum, 'whitespace/braces', 4, + '{ should almost always be at the end of the previous line') # An else clause should be on the same line as the preceding closing brace. - if Match(r'\s*}\s*else\b\s*(?:if\b|\{|$)', line): - error(filename, linenum, 'whitespace/newline', 4, - 'An else should appear on a new line after }') + if Match(r'\s*else\b\s*(?:if\b|\{|$)', line): + prevline = GetPreviousNonBlankLine(clean_lines, linenum)[0] + if Match(r'\s*}\s*$', prevline): + error(filename, linenum, 'whitespace/newline', 4, + 'An else should appear on the same line as the preceding }') # If braces come on one side of an else, they should be on both. # However, we have to worry about "else if" that spans multiple lines! @@ -3802,11 +4317,11 @@ def CheckBraces(filename, clean_lines, linenum, error): # its line, and the line after that should have an indent level equal to or # lower than the if. We also check for ambiguous if/else nesting without # braces. - if_else_match = Search(r'\b(if\s*\(|else\b)', line) + if_else_match = Search(r'\b(if\s*(|constexpr)\s*\(|else\b)', line) if if_else_match and not Match(r'\s*#', line): if_indent = GetIndentLevel(line) endline, endlinenum, endpos = line, linenum, if_else_match.end() - if_match = Search(r'\bif\s*\(', line) + if_match = Search(r'\bif\s*(|constexpr)\s*\(', line) if if_match: # This could be a multiline if condition, so find the end first. pos = if_match.end() - 1 @@ -3865,9 +4380,9 @@ def CheckTrailingSemicolon(filename, clean_lines, linenum, error): # Block bodies should not be followed by a semicolon. Due to C++11 # brace initialization, there are more places where semicolons are - # required than not, so we use a whitelist approach to check these - # rather than a blacklist. These are the places where "};" should - # be replaced by just "}": + # required than not, so we explicitly list the allowed rules rather + # than listing the disallowed ones. These are the places where "};" + # should be replaced by just "}": # 1. Some flavor of block following closing parenthesis: # for (;;) {}; # while (...) {}; @@ -3923,11 +4438,11 @@ def CheckTrailingSemicolon(filename, clean_lines, linenum, error): # - INTERFACE_DEF # - EXCLUSIVE_LOCKS_REQUIRED, SHARED_LOCKS_REQUIRED, LOCKS_EXCLUDED: # - # We implement a whitelist of safe macros instead of a blacklist of + # We implement a list of safe macros instead of a list of # unsafe macros, even though the latter appears less frequently in # google code and would have been easier to implement. This is because - # the downside for getting the whitelist wrong means some extra - # semicolons, while the downside for getting the blacklist wrong + # the downside for getting the allowed checks wrong means some extra + # semicolons, while the downside for getting disallowed checks wrong # would result in compile errors. # # In addition to macros, we also don't want to warn on @@ -4028,13 +4543,6 @@ def CheckEmptyBlockBody(filename, clean_lines, linenum, error): if matched.group(1) == 'if': error(filename, end_linenum, 'whitespace/empty_conditional_body', 5, 'Empty conditional bodies should use {}') - elif matched.group(1) == 'while' and linenum is not 0 \ - and "}" in clean_lines.elided[linenum-1]: - # Don't report an error for do-while loops. Works - # by checking for a closing brace on the previous - # line, since that means it's probably a do-while - # loop. - return else: error(filename, end_linenum, 'whitespace/empty_loop_body', 5, 'Empty loop bodies should use {} or continue') @@ -4078,12 +4586,12 @@ def CheckEmptyBlockBody(filename, clean_lines, linenum, error): return if closing_linenum > opening_linenum: # Opening line after the {. Ignore comments here since we checked above. - body = list(opening_line[opening_pos+1:]) + bodylist = list(opening_line[opening_pos+1:]) # All lines until closing line, excluding closing line, with comments. - body.extend(clean_lines.raw_lines[opening_linenum+1:closing_linenum]) + bodylist.extend(clean_lines.raw_lines[opening_linenum+1:closing_linenum]) # Closing line before the }. Won't (and can't) have comments. - body.append(clean_lines.elided[closing_linenum][:closing_pos-1]) - body = '\n'.join(body) + bodylist.append(clean_lines.elided[closing_linenum][:closing_pos-1]) + body = '\n'.join(bodylist) else: # If statement has brackets and fits on a single line. body = opening_line[opening_pos+1:closing_pos-1] @@ -4298,6 +4806,16 @@ def GetLineWidth(line): if unicodedata.east_asian_width(uc) in ('W', 'F'): width += 2 elif not unicodedata.combining(uc): + # Issue 337 + # https://mail.python.org/pipermail/python-list/2012-August/628809.html + if (sys.version_info.major, sys.version_info.minor) <= (3, 2): + # https://github.com/python/cpython/blob/2.7/Include/unicodeobject.h#L81 + is_wide_build = sysconfig.get_config_var("Py_UNICODE_SIZE") >= 4 + # https://github.com/python/cpython/blob/2.7/Objects/unicodeobject.c#L564 + is_low_surrogate = 0xDC00 <= ord(uc) <= 0xDFFF + if not is_wide_build and is_low_surrogate: + width -= 1 + width += 1 return width else: @@ -4345,7 +4863,7 @@ def CheckStyle(filename, clean_lines, linenum, file_extension, nesting_state, # if(match($0, " <<")) complain = 0; # if(match(prev, " +for \\(")) complain = 0; # if(prevodd && match(prevprev, " +for \\(")) complain = 0; - scope_or_label_pattern = r'\s*\w+\s*:\s*\\?$' + scope_or_label_pattern = r'\s*(?:public|private|protected|signals)(?:\s+(?:slots\s*)?)?:\s*\\?$' classinfo = nesting_state.InnermostClass() initial_spaces = 0 cleansed_line = clean_lines.elided[linenum] @@ -4385,16 +4903,23 @@ def CheckStyle(filename, clean_lines, linenum, file_extension, nesting_state, # # The "$Id:...$" comment may also get very long without it being the # developers fault. + # + # Doxygen documentation copying can get pretty long when using an overloaded + # function declaration if (not line.startswith('#include') and not is_header_guard and not Match(r'^\s*//.*http(s?)://\S*$', line) and not Match(r'^\s*//\s*[^\s]*$', line) and - not Match(r'^// \$Id:.*#[0-9]+ \$$', line)): + not Match(r'^// \$Id:.*#[0-9]+ \$$', line) and + not Match(r'^\s*/// [@\\](copydoc|copydetails|copybrief) .*$', line)): line_width = GetLineWidth(line) if line_width > _line_length: error(filename, linenum, 'whitespace/line_length', 2, 'Lines should be <= %i characters long' % _line_length) if (cleansed_line.count(';') > 1 and + # allow simple single line lambdas + not Match(r'^[^{};]*\[[^\[\]]*\][^{}]*\{[^{}\n\r]*\}', + line) and # for loops are allowed two ;'s (and may run over two lines). cleansed_line.find('for') == -1 and (GetPreviousNonBlankLine(clean_lines, linenum)[0].find('for') == -1 or @@ -4451,21 +4976,25 @@ def _DropCommonSuffixes(filename): Returns: The filename with the common suffix removed. """ - for suffix in ('test.cc', 'regtest.cc', 'unittest.cc', - 'inl.h', 'impl.h', 'internal.h'): + for suffix in itertools.chain( + ('%s.%s' % (test_suffix.lstrip('_'), ext) + for test_suffix, ext in itertools.product(_test_suffixes, GetNonHeaderExtensions())), + ('%s.%s' % (suffix, ext) + for suffix, ext in itertools.product(['inl', 'imp', 'internal'], GetHeaderExtensions()))): if (filename.endswith(suffix) and len(filename) > len(suffix) and filename[-len(suffix) - 1] in ('-', '_')): return filename[:-len(suffix) - 1] return os.path.splitext(filename)[0] -def _ClassifyInclude(fileinfo, include, is_system): +def _ClassifyInclude(fileinfo, include, used_angle_brackets, include_order="default"): """Figures out what kind of header 'include' is. Args: fileinfo: The current file cpplint is running over. A FileInfo instance. include: The path to a #included file. - is_system: True if the #include used <> rather than "". + used_angle_brackets: True if the #include used <> rather than "". + include_order: "default" or other value allowed in program arguments Returns: One of the _XXX_HEADER constants. @@ -4475,6 +5004,8 @@ def _ClassifyInclude(fileinfo, include, is_system): _C_SYS_HEADER >>> _ClassifyInclude(FileInfo('foo/foo.cc'), 'string', True) _CPP_SYS_HEADER + >>> _ClassifyInclude(FileInfo('foo/foo.cc'), 'foo/foo.h', True, "standardcfirst") + _OTHER_SYS_HEADER >>> _ClassifyInclude(FileInfo('foo/foo.cc'), 'foo/foo.h', False) _LIKELY_MY_HEADER >>> _ClassifyInclude(FileInfo('foo/foo_unknown_extension.cc'), @@ -4485,13 +5016,23 @@ def _ClassifyInclude(fileinfo, include, is_system): """ # This is a list of all standard c++ header files, except # those already checked for above. - is_cpp_h = include in _CPP_HEADERS + is_cpp_header = include in _CPP_HEADERS + + # Mark include as C header if in list or in a known folder for standard-ish C headers. + is_std_c_header = (include_order == "default") or (include in _C_HEADERS + # additional linux glibc header folders + or Search(r'(?:%s)\/.*\.h' % "|".join(C_STANDARD_HEADER_FOLDERS), include)) + + # Headers with C++ extensions shouldn't be considered C system headers + is_system = used_angle_brackets and not os.path.splitext(include)[1] in ['.hpp', '.hxx', '.h++'] if is_system: - if is_cpp_h or include.endswith(".hh"): + if is_cpp_header: return _CPP_SYS_HEADER - else: + if is_std_c_header: return _C_SYS_HEADER + else: + return _OTHER_SYS_HEADER # If the target file and the include we're checking share a # basename when we drop common extensions, and the include @@ -4499,9 +5040,11 @@ def _ClassifyInclude(fileinfo, include, is_system): target_dir, target_base = ( os.path.split(_DropCommonSuffixes(fileinfo.RepositoryName()))) include_dir, include_base = os.path.split(_DropCommonSuffixes(include)) + target_dir_pub = os.path.normpath(target_dir + '/../public') + target_dir_pub = target_dir_pub.replace('\\', '/') if target_base == include_base and ( include_dir == target_dir or - include_dir == os.path.normpath(target_dir + '/../public')): + include_dir == target_dir_pub): return _LIKELY_MY_HEADER # If the target and include share some initial basename @@ -4543,10 +5086,10 @@ def CheckIncludeLine(filename, clean_lines, linenum, include_state, error): # # We also make an exception for Lua headers, which follow google # naming convention but not the include convention. - # match = Match(r'#include\s*"([^/]+\.h)"', line) - # if match and not _THIRD_PARTY_HEADERS_PATTERN.match(match.group(1)): - # error(filename, linenum, 'build/include', 4, - # 'Include the directory when naming .h files') + match = Match(r'#include\s*"([^/]+\.h)"', line) + if match and not _THIRD_PARTY_HEADERS_PATTERN.match(match.group(1)): + error(filename, linenum, 'build/include_subdir', 4, + 'Include the directory when naming .h files') # we shouldn't include a file more than once. actually, there are a # handful of instances where doing so is okay, but in general it's @@ -4554,17 +5097,34 @@ def CheckIncludeLine(filename, clean_lines, linenum, include_state, error): match = _RE_PATTERN_INCLUDE.search(line) if match: include = match.group(2) - is_system = (match.group(1) == '<') + used_angle_brackets = (match.group(1) == '<') duplicate_line = include_state.FindHeader(include) if duplicate_line >= 0: error(filename, linenum, 'build/include', 4, '"%s" already included at %s:%s' % (include, filename, duplicate_line)) - elif (include.endswith('.cc') and + return + + for extension in GetNonHeaderExtensions(): + if (include.endswith('.' + extension) and os.path.dirname(fileinfo.RepositoryName()) != os.path.dirname(include)): - error(filename, linenum, 'build/include', 4, - 'Do not include .cc files from other packages') - elif not _THIRD_PARTY_HEADERS_PATTERN.match(include): + error(filename, linenum, 'build/include', 4, + 'Do not include .' + extension + ' files from other packages') + return + + # We DO want to include a 3rd party looking header if it matches the + # filename. Otherwise we get an erroneous error "...should include its + # header" error later. + third_src_header = False + for ext in GetHeaderExtensions(): + basefilename = filename[0:len(filename) - len(fileinfo.Extension())] + headerfile = basefilename + '.' + ext + headername = FileInfo(headerfile).RepositoryName() + if headername in include or include in headername: + third_src_header = True + break + + if third_src_header or not _THIRD_PARTY_HEADERS_PATTERN.match(include): include_state.include_list[-1].append((include, linenum)) # We want to ensure that headers appear in the right order: @@ -4579,7 +5139,7 @@ def CheckIncludeLine(filename, clean_lines, linenum, include_state, error): # track of the highest type seen, and complains if we see a # lower type after that. error_message = include_state.CheckNextIncludeOrder( - _ClassifyInclude(fileinfo, include, is_system)) + _ClassifyInclude(fileinfo, include, used_angle_brackets, _include_order)) if error_message: error(filename, linenum, 'build/include_order', 4, '%s. Should be: %s.h, c system, c++ system, other.' % @@ -4618,7 +5178,7 @@ def _GetTextInside(text, start_pattern): # Give opening punctuations to get the matching close-punctuations. matching_punctuation = {'(': ')', '{': '}', '[': ']'} - closing_punctuation = set(matching_punctuation.itervalues()) + closing_punctuation = set(itervalues(matching_punctuation)) # Find the position to start extracting text. match = re.search(start_pattern, text, re.M) @@ -4712,8 +5272,6 @@ def CheckLanguage(filename, clean_lines, linenum, file_extension, if match: include_state.ResetSection(match.group(1)) - # Make Windows paths like Unix. - fullname = os.path.abspath(filename).replace('\\', '/') # Perform other checks now that we are sure that this is not an include line CheckCasts(filename, clean_lines, linenum, error) @@ -4780,10 +5338,15 @@ def CheckLanguage(filename, clean_lines, linenum, file_extension, 'Did you mean "memset(%s, 0, %s)"?' % (match.group(1), match.group(2))) - # if Search(r'\busing namespace\b', line): - # error(filename, linenum, 'build/namespaces', 5, - # 'Do not use namespace using-directives. ' - # 'Use using-declarations instead.') + if Search(r'\busing namespace\b', line): + if Search(r'\bliterals\b', line): + error(filename, linenum, 'build/namespaces_literals', 5, + 'Do not use namespace using-directives. ' + 'Use using-declarations instead.') + else: + error(filename, linenum, 'build/namespaces', 5, + 'Do not use namespace using-directives. ' + 'Use using-declarations instead.') # Detect variable-length arrays. match = Match(r'\s*(.+::)?(\w+) [a-z]\w*\[(.+)];', line) @@ -4830,7 +5393,7 @@ def CheckLanguage(filename, clean_lines, linenum, file_extension, if (IsHeaderExtension(file_extension) and Search(r'\bnamespace\s*{', line) and line[-1] != '\\'): - error(filename, linenum, 'build/namespaces', 4, + error(filename, linenum, 'build/namespaces_headers', 4, 'Do not use unnamed namespaces in header files. See ' 'https://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Namespaces' ' for more information.') @@ -5120,29 +5683,29 @@ def CheckForNonConstReference(filename, clean_lines, linenum, # # We also accept & in static_assert, which looks like a function but # it's actually a declaration expression. - whitelisted_functions = (r'(?:[sS]wap(?:<\w:+>)?|' + allowed_functions = (r'(?:[sS]wap(?:<\w:+>)?|' r'operator\s*[<>][<>]|' r'static_assert|COMPILE_ASSERT' r')\s*\(') - if Search(whitelisted_functions, line): + if Search(allowed_functions, line): return elif not Search(r'\S+\([^)]*$', line): - # Don't see a whitelisted function on this line. Actually we + # Don't see an allowed function on this line. Actually we # didn't see any function name on this line, so this is likely a # multi-line parameter list. Try a bit harder to catch this case. for i in xrange(2): if (linenum > i and - Search(whitelisted_functions, clean_lines.elided[linenum - i - 1])): + Search(allowed_functions, clean_lines.elided[linenum - i - 1])): return decls = ReplaceAll(r'{[^}]*}', ' ', line) # exclude function body - # for parameter in re.findall(_RE_PATTERN_REF_PARAM, decls): - # if (not Match(_RE_PATTERN_CONST_REF_PARAM, parameter) and - # not Match(_RE_PATTERN_REF_STREAM_PARAM, parameter)): - # error(filename, linenum, 'runtime/references', 2, - # 'Is this a non-const reference? ' - # 'If so, make const or use a pointer: ' + - # ReplaceAll(' *<', '<', parameter)) + for parameter in re.findall(_RE_PATTERN_REF_PARAM, decls): + if (not Match(_RE_PATTERN_CONST_REF_PARAM, parameter) and + not Match(_RE_PATTERN_REF_STREAM_PARAM, parameter)): + error(filename, linenum, 'runtime/references', 2, + 'Is this a non-const reference? ' + 'If so, make const or use a pointer: ' + + ReplaceAll(' *<', '<', parameter)) def CheckCasts(filename, clean_lines, linenum, error): @@ -5287,8 +5850,6 @@ def CheckCStyleCast(filename, clean_lines, linenum, cast_type, pattern, error): # Exclude lines with keywords that tend to look like casts context = line[0:match.start(1) - 1] - if Match(r'^\s*(private|public):.*$', context): - return False if Match(r'.*\b(?:sizeof|alignof|alignas|[_A-Z][_A-Z0-9]*)\s*$', context): return False @@ -5362,11 +5923,11 @@ def ExpectingFunctionArgs(clean_lines, linenum): )), ('', ('numeric_limits',)), ('', ('list',)), - ('', ('map', 'multimap',)), + ('', ('multimap',)), ('', ('allocator', 'make_shared', 'make_unique', 'shared_ptr', 'unique_ptr', 'weak_ptr')), ('', ('queue', 'priority_queue',)), - ('', ('set', 'multiset',)), + ('', ('multiset',)), ('', ('stack',)), ('', ('char_traits', 'basic_string',)), ('', ('tuple',)), @@ -5395,11 +5956,21 @@ def ExpectingFunctionArgs(clean_lines, linenum): for _header, _templates in _HEADERS_MAYBE_TEMPLATES: for _template in _templates: # Match max(..., ...), max(..., ...), but not foo->max, foo.max or - # type::max(). + # 'type::max()'. _re_pattern_headers_maybe_templates.append( (re.compile(r'[^>.]\b' + _template + r'(<.*?>)?\([^\)]'), _template, _header)) +# Match set, but not foo->set, foo.set +_re_pattern_headers_maybe_templates.append( + (re.compile(r'[^>.]\bset\s*\<'), + 'set<>', + '')) +# Match 'map var' and 'std::map(...)', but not 'map(...)'' +_re_pattern_headers_maybe_templates.append( + (re.compile(r'(std\b::\bmap\s*\<)|(^(std\b::\b)map\b\(\s*\<)'), + 'map<>', + '')) # Other scripts may reach in and modify this pattern. _re_pattern_templates = [] @@ -5432,7 +6003,7 @@ def FilesBelongToSameModule(filename_cc, filename_h): some false positives. This should be sufficiently rare in practice. Args: - filename_cc: is the path for the .cc file + filename_cc: is the path for the source (e.g. .cc) file filename_h: is the path for the header path Returns: @@ -5440,20 +6011,23 @@ def FilesBelongToSameModule(filename_cc, filename_h): bool: True if filename_cc and filename_h belong to the same module. string: the additional prefix needed to open the header file. """ + fileinfo_cc = FileInfo(filename_cc) + if not fileinfo_cc.Extension().lstrip('.') in GetNonHeaderExtensions(): + return (False, '') - fileinfo = FileInfo(filename_cc) - if not fileinfo.IsSource(): + fileinfo_h = FileInfo(filename_h) + if not IsHeaderExtension(fileinfo_h.Extension().lstrip('.')): return (False, '') - filename_cc = filename_cc[:-len(fileinfo.Extension())] - matched_test_suffix = Search(_TEST_FILE_SUFFIX, fileinfo.BaseName()) + + filename_cc = filename_cc[:-(len(fileinfo_cc.Extension()))] + matched_test_suffix = Search(_TEST_FILE_SUFFIX, fileinfo_cc.BaseName()) if matched_test_suffix: filename_cc = filename_cc[:-len(matched_test_suffix.group(1))] + filename_cc = filename_cc.replace('/public/', '/') filename_cc = filename_cc.replace('/internal/', '/') - if not filename_h.endswith('.h'): - return (False, '') - filename_h = filename_h[:-len('.h')] + filename_h = filename_h[:-(len(fileinfo_h.Extension()))] if filename_h.endswith('-inl'): filename_h = filename_h[:-len('-inl')] filename_h = filename_h.replace('/public/', '/') @@ -5479,18 +6053,19 @@ def UpdateIncludeState(filename, include_dict, io=codecs): """ headerfile = None try: - headerfile = io.open(filename, 'r', 'utf8', 'replace') + with io.open(filename, 'r', 'utf8', 'replace') as headerfile: + linenum = 0 + for line in headerfile: + linenum += 1 + clean_line = CleanseComments(line) + match = _RE_PATTERN_INCLUDE.search(clean_line) + if match: + include = match.group(2) + include_dict.setdefault(include, linenum) + return True except IOError: return False - linenum = 0 - for line in headerfile: - linenum += 1 - clean_line = CleanseComments(line) - match = _RE_PATTERN_INCLUDE.search(clean_line) - if match: - include = match.group(2) - include_dict.setdefault(include, linenum) - return True + def CheckForIncludeWhatYouUse(filename, clean_lines, include_state, error, @@ -5568,7 +6143,7 @@ def CheckForIncludeWhatYouUse(filename, clean_lines, include_state, error, # include_dict is modified during iteration, so we iterate over a copy of # the keys. - header_keys = include_dict.keys() + header_keys = list(include_dict.keys()) for header in header_keys: (same_module, common_path) = FilesBelongToSameModule(abs_filename, header) fullpath = common_path + header @@ -5580,11 +6155,13 @@ def CheckForIncludeWhatYouUse(filename, clean_lines, include_state, error, # didn't include it in the .h file. # TODO(unknown): Do a better job of finding .h files so we are confident that # not having the .h file means there isn't one. - if filename.endswith('.cc') and not header_found: - return + if not header_found: + for extension in GetNonHeaderExtensions(): + if filename.endswith('.' + extension): + return # All the lines have been processed, report the errors found. - for required_header_unstripped in required: + for required_header_unstripped in sorted(required, key=required.__getitem__): template = required[required_header_unstripped][1] if required_header_unstripped.strip('<>"') not in include_dict: error(filename, required[required_header_unstripped][0], @@ -5702,6 +6279,12 @@ def CheckRedundantOverrideOrFinal(filename, clean_lines, linenum, error): else: return + # Check that at most one of "override" or "final" is present, not both + if Search(r'\boverride\b', fragment) and Search(r'\bfinal\b', fragment): + error(filename, linenum, 'readability/inheritance', 4, + ('"override" is redundant since function is ' + 'already declared as "final"')) + @@ -5717,11 +6300,9 @@ def IsBlockInNameSpace(nesting_state, is_forward_declaration): Whether or not the new block is directly in a namespace. """ if is_forward_declaration: - if len(nesting_state.stack) >= 1 and ( - isinstance(nesting_state.stack[-1], _NamespaceInfo)): - return True - else: - return False + return len(nesting_state.stack) >= 1 and ( + isinstance(nesting_state.stack[-1], _NamespaceInfo)) + return (len(nesting_state.stack) > 1 and nesting_state.stack[-1].check_namespace_indentation and @@ -5764,14 +6345,14 @@ def ShouldCheckNamespaceIndentation(nesting_state, is_namespace_indent_item, def CheckItemIndentationInNamespace(filename, raw_lines_no_comments, linenum, error): line = raw_lines_no_comments[linenum] - # if Match(r'^\s+', line): - # error(filename, linenum, 'runtime/indentation_namespace', 4, - # 'Do not indent within a namespace') + if Match(r'^\s+', line): + error(filename, linenum, 'runtime/indentation_namespace', 4, + 'Do not indent within a namespace') def ProcessLine(filename, file_extension, clean_lines, line, include_state, function_state, nesting_state, error, - extra_check_functions=[]): + extra_check_functions=None): """Processes a single line in the file. Args: @@ -5810,8 +6391,9 @@ def ProcessLine(filename, file_extension, clean_lines, line, CheckMakePairUsesDeduction(filename, clean_lines, line, error) CheckRedundantVirtual(filename, clean_lines, line, error) CheckRedundantOverrideOrFinal(filename, clean_lines, line, error) - for check_fn in extra_check_functions: - check_fn(filename, clean_lines, line, error) + if extra_check_functions: + for check_fn in extra_check_functions: + check_fn(filename, clean_lines, line, error) def FlagCxx11Features(filename, clean_lines, linenum, error): """Flag those c++11 features that we only allow in certain places. @@ -5833,7 +6415,14 @@ def FlagCxx11Features(filename, clean_lines, linenum, error): # Flag unapproved C++11 headers. if include and include.group(1) in ('cfenv', + 'condition_variable', 'fenv.h', + 'future', + 'mutex', + 'thread', + 'chrono', + 'ratio', + 'regex', 'system_error', ): error(filename, linenum, 'build/c++11', 5, @@ -5878,7 +6467,7 @@ def FlagCxx14Features(filename, clean_lines, linenum, error): def ProcessFileData(filename, file_extension, lines, error, - extra_check_functions=[]): + extra_check_functions=None): """Performs lint checks and reports any errors to the given error function. Args: @@ -5978,7 +6567,7 @@ def ProcessConfigOverrides(filename): if _cpplint_state.quiet: # Suppress "Ignoring file" warning when using --quiet. return False - sys.stderr.write('Ignoring "%s": file excluded by "%s". ' + _cpplint_state.PrintInfo('Ignoring "%s": file excluded by "%s". ' 'File path component "%s" matches ' 'pattern "%s"\n' % (filename, cfg_file, base_name, val)) @@ -5986,34 +6575,38 @@ def ProcessConfigOverrides(filename): elif name == 'linelength': global _line_length try: - _line_length = int(val) + _line_length = int(val) except ValueError: - sys.stderr.write('Line length must be numeric.') + _cpplint_state.PrintError('Line length must be numeric.') + elif name == 'extensions': + ProcessExtensionsOption(val) elif name == 'root': global _root # root directories are specified relative to CPPLINT.cfg dir. _root = os.path.join(os.path.dirname(cfg_file), val) elif name == 'headers': ProcessHppHeadersOption(val) + elif name == 'includeorder': + ProcessIncludeOrderOption(val) else: - sys.stderr.write( + _cpplint_state.PrintError( 'Invalid configuration option (%s) in file %s\n' % (name, cfg_file)) except IOError: - sys.stderr.write( + _cpplint_state.PrintError( "Skipping config file '%s': Can't open for reading\n" % cfg_file) keep_looking = False # Apply all the accumulated filters in reverse order (top-level directory # config options having the least priority). - for filter in reversed(cfg_filters): - _AddFilters(filter) + for cfg_filter in reversed(cfg_filters): + _AddFilters(cfg_filter) return True -def ProcessFile(filename, vlevel, extra_check_functions=[]): +def ProcessFile(filename, vlevel, extra_check_functions=None): """Does google-lint on a single file. Args: @@ -6051,7 +6644,8 @@ def ProcessFile(filename, vlevel, extra_check_functions=[]): codecs.getwriter('utf8'), 'replace').read().split('\n') else: - lines = codecs.open(filename, 'r', 'utf8', 'replace').read().split('\n') + with codecs.open(filename, 'r', 'utf8', 'replace') as target_file: + lines = target_file.read().split('\n') # Remove trailing '\r'. # The -1 accounts for the extra trailing blank line we get from split() @@ -6063,7 +6657,7 @@ def ProcessFile(filename, vlevel, extra_check_functions=[]): lf_lines.append(linenum + 1) except IOError: - sys.stderr.write( + _cpplint_state.PrintError( "Skipping input '%s': Can't open for reading\n" % filename) _RestoreFilters() return @@ -6073,10 +6667,11 @@ def ProcessFile(filename, vlevel, extra_check_functions=[]): # When reading from stdin, the extension is unknown, so no cpplint tests # should rely on the extension. - if filename != '-' and file_extension not in _valid_extensions: - if not _Quiet(): - sys.stderr.write('Ignoring %s; not a valid file name ' - '(%s)\n' % (filename, ', '.join(_valid_extensions))) + if filename != '-' and file_extension not in GetAllExtensions(): + pass + # Ignition: never print this + # _cpplint_state.PrintError('Ignoring %s; not a valid file name ' + # '(%s)\n' % (filename, ', '.join(GetAllExtensions()))) else: ProcessFileData(filename, file_extension, lines, Error, extra_check_functions) @@ -6101,8 +6696,10 @@ def ProcessFile(filename, vlevel, extra_check_functions=[]): # Suppress printing anything if --quiet was passed unless the error # count has increased after processing this file. - # if not _cpplint_state.quiet or old_errors != _cpplint_state.error_count: - # sys.stdout.write('Done processing %s\n' % filename) + if not _cpplint_state.quiet or old_errors != _cpplint_state.error_count: + pass + # Ignition: never print "Done Processing" + # _cpplint_state.PrintInfo('Done processing %s\n' % filename) _RestoreFilters() @@ -6112,12 +6709,21 @@ def PrintUsage(message): Args: message: The optional error message. """ - sys.stderr.write(_USAGE) + sys.stderr.write(_USAGE % (list(GetAllExtensions()), + ','.join(list(GetAllExtensions())), + GetHeaderExtensions(), + ','.join(GetHeaderExtensions()))) + if message: sys.exit('\nFATAL ERROR: ' + message) else: - sys.exit(1) + sys.exit(0) +def PrintVersion(): + sys.stdout.write('Cpplint fork (https://github.com/cpplint/cpplint)\n') + sys.stdout.write('cpplint ' + __VERSION__ + '\n') + sys.stdout.write('Python ' + sys.version + '\n') + sys.exit(0) def PrintCategories(): """Prints a list of all the error-categories used by error messages. @@ -6141,12 +6747,18 @@ def ParseArguments(args): """ try: (opts, filenames) = getopt.getopt(args, '', ['help', 'output=', 'verbose=', + 'v=', + 'version', 'counting=', 'filter=', 'root=', + 'repository=', 'linelength=', 'extensions=', + 'exclude=', + 'recursive', 'headers=', + 'includeorder=', 'quiet']) except getopt.GetoptError: PrintUsage('Invalid arguments.') @@ -6156,17 +6768,21 @@ def ParseArguments(args): filters = '' quiet = _Quiet() counting_style = '' + recursive = False for (opt, val) in opts: if opt == '--help': PrintUsage(None) + if opt == '--version': + PrintVersion() elif opt == '--output': - if val not in ('emacs', 'vs7', 'eclipse'): - PrintUsage('The only allowed output formats are emacs, vs7 and eclipse.') + if val not in ('emacs', 'vs7', 'eclipse', 'junit', 'sed', 'gsed'): + PrintUsage('The only allowed output formats are emacs, vs7, eclipse ' + 'sed, gsed and junit.') output_format = val elif opt == '--quiet': quiet = True - elif opt == '--verbose': + elif opt == '--verbose' or opt == '--v': verbosity = int(val) elif opt == '--filter': filters = val @@ -6179,49 +6795,126 @@ def ParseArguments(args): elif opt == '--root': global _root _root = val + elif opt == '--repository': + global _repository + _repository = val elif opt == '--linelength': global _line_length try: - _line_length = int(val) + _line_length = int(val) except ValueError: - PrintUsage('Line length must be digits.') + PrintUsage('Line length must be digits.') + elif opt == '--exclude': + global _excludes + if not _excludes: + _excludes = set() + _excludes.update(glob.glob(val)) elif opt == '--extensions': - global _valid_extensions - try: - _valid_extensions = set(val.split(',')) - except ValueError: - PrintUsage('Extensions must be comma seperated list.') + ProcessExtensionsOption(val) elif opt == '--headers': ProcessHppHeadersOption(val) + elif opt == '--recursive': + recursive = True + elif opt == '--includeorder': + ProcessIncludeOrderOption(val) if not filenames: PrintUsage('No files were specified.') + if recursive: + filenames = _ExpandDirectories(filenames) + + if _excludes: + filenames = _FilterExcludedFiles(filenames) + _SetOutputFormat(output_format) _SetQuiet(quiet) _SetVerboseLevel(verbosity) _SetFilters(filters) _SetCountingStyle(counting_style) + filenames.sort() return filenames +def _ExpandDirectories(filenames): + """Searches a list of filenames and replaces directories in the list with + all files descending from those directories. Files with extensions not in + the valid extensions list are excluded. -def main(): - filenames = ParseArguments(sys.argv[1:]) - - # Change stderr to write with replacement characters so we don't die - # if we try to print something containing non-ASCII characters. - sys.stderr = codecs.StreamReaderWriter(sys.stderr, - codecs.getreader('utf8'), - codecs.getwriter('utf8'), - 'replace') + Args: + filenames: A list of files or directories - _cpplint_state.ResetErrorCounts() + Returns: + A list of all files that are members of filenames or descended from a + directory in filenames + """ + expanded = set() for filename in filenames: - ProcessFile(filename, _cpplint_state.verbose_level) - # If --quiet is passed, suppress printing error count unless there are errors. - if not _cpplint_state.quiet or _cpplint_state.error_count > 0: - _cpplint_state.PrintErrorCounts() + if not os.path.isdir(filename): + expanded.add(filename) + continue + + for root, _, files in os.walk(filename): + for loopfile in files: + fullname = os.path.join(root, loopfile) + if fullname.startswith('.' + os.path.sep): + fullname = fullname[len('.' + os.path.sep):] + expanded.add(fullname) + + filtered = [] + for filename in expanded: + if os.path.splitext(filename)[1][1:] in GetAllExtensions(): + filtered.append(filename) + return filtered + +def _FilterExcludedFiles(fnames): + """Filters out files listed in the --exclude command line switch. File paths + in the switch are evaluated relative to the current working directory + """ + exclude_paths = [os.path.abspath(f) for f in _excludes] + # because globbing does not work recursively, exclude all subpath of all excluded entries + return [f for f in fnames + if not any(e for e in exclude_paths + if _IsParentOrSame(e, os.path.abspath(f)))] + +def _IsParentOrSame(parent, child): + """Return true if child is subdirectory of parent. + Assumes both paths are absolute and don't contain symlinks. + """ + parent = os.path.normpath(parent) + child = os.path.normpath(child) + if parent == child: + return True + + prefix = os.path.commonprefix([parent, child]) + if prefix != parent: + return False + # Note: os.path.commonprefix operates on character basis, so + # take extra care of situations like '/foo/ba' and '/foo/bar/baz' + child_suffix = child[len(prefix):] + child_suffix = child_suffix.lstrip(os.sep) + return child == os.path.join(prefix, child_suffix) + +def main(): + filenames = ParseArguments(sys.argv[1:]) + backup_err = sys.stderr + try: + # Change stderr to write with replacement characters so we don't die + # if we try to print something containing non-ASCII characters. + sys.stderr = codecs.StreamReader(sys.stderr, 'replace') + + _cpplint_state.ResetErrorCounts() + for filename in filenames: + ProcessFile(filename, _cpplint_state.verbose_level) + # If --quiet is passed, suppress printing error count unless there are errors. + if not _cpplint_state.quiet or _cpplint_state.error_count > 0: + _cpplint_state.PrintErrorCounts() + + if _cpplint_state.output_format == 'junit': + sys.stderr.write(_cpplint_state.FormatJUnitXML()) + + finally: + sys.stderr = backup_err sys.exit(_cpplint_state.error_count > 0) From 6a646e9201d84d7945b6aad4c12b0fa43d6af6f0 Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Mon, 16 Nov 2020 09:31:04 -0800 Subject: [PATCH 41/69] FindIgnOGRE2: prefer versioned component libraries (#125) Both ogre1.9 and ogre2.1 install component libraries named libOgreOverlay. For ogre1.9, an unversioned symbolic link is installed directly into the lib folder, while in our debian libogre-2.1-dev and brew ogre2.1 packages, an unversioned symbolic link is installed in lib/OGRE-2.1. This find module uses find_library to find Ogre component libraries with HINTS pointing to the lib/OGRE-2.1 subfolder, which is helpful but limited because the CMAKE_PREFIX_PATH is searched before the HINTS. When building ignition-rendering with homebrew, the CMAKE_PREFIX_PATH may include /usr/local, which causes the libOgreOverlay library from ogre1.9 to be found before the version from ogre2.1. On macOS, the following are in /usr/local/lib: /usr/local/lib/libOgreOverlay.1.9.0.dylib /usr/local/lib/libOgreOverlay.2.1.0.dylib /usr/local/lib/libOgreOverlay.dylib (sym-link to 1.9.0) This causes find_library to prefer a library name with the version appended before the suffix, while still accepting unversioned names if a versioned name is not found. Signed-off-by: Steve Peters --- cmake/FindIgnOGRE2.cmake | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmake/FindIgnOGRE2.cmake b/cmake/FindIgnOGRE2.cmake index d48a2f80..b94166aa 100644 --- a/cmake/FindIgnOGRE2.cmake +++ b/cmake/FindIgnOGRE2.cmake @@ -211,7 +211,11 @@ if (NOT WIN32) # find ogre components include(IgnImportTarget) foreach(component ${IgnOGRE2_FIND_COMPONENTS}) - find_library(OGRE2-${component} NAMES "Ogre${component}" HINTS ${OGRE2_LIBRARY_DIRS}) + find_library(OGRE2-${component} + NAMES + "Ogre${component}.${OGRE2_VERSION}" + "Ogre${component}" + HINTS ${OGRE2_LIBRARY_DIRS}) if (NOT "OGRE2-${component}" STREQUAL "OGRE2-${component}-NOTFOUND") # create a new target for each component From 106187d506292579ee1a717bfd36094d7a531a75 Mon Sep 17 00:00:00 2001 From: Silvio Traversaro Date: Mon, 16 Nov 2020 20:37:22 +0100 Subject: [PATCH 42/69] Fix FindIgnOgre on Windows when not using vcpkg (#124) The current version of FindIgnOgre contains a vcpkg-specific workaround on the location of the OgreMain library, that is fixed to point to the "${OGRE_LIBRARY_DIRS}/manual-link/" directory, that it is its location when Ogre is installed by vcpkg. However, this creates a problem when installing Ogre with other package managers on Windows, for example when using conda-forge or conan. To mitigate this problem, we only set the location of the OgreMain library to be "${OGRE_LIBRARY_DIRS}/manual-link/" only if this directory exists, that is only true for vcpkg installations. Signed-off-by: Silvio Traversaro Co-authored-by: Jose Luis Rivero Co-authored-by: Louise Poubel --- cmake/FindIgnOGRE.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/FindIgnOGRE.cmake b/cmake/FindIgnOGRE.cmake index b86c66ba..3c7b9e18 100644 --- a/cmake/FindIgnOGRE.cmake +++ b/cmake/FindIgnOGRE.cmake @@ -178,7 +178,7 @@ else() set(prefix "") # vcpkg uses special directory (lib/manual-link/) to place libraries # with main sysmbol like OgreMain. - if(ogre_lib MATCHES "OgreMain" AND NOT IS_ABSOLUTE "${ogre_lib}") + if(ogre_lib MATCHES "OgreMain" AND NOT IS_ABSOLUTE "${ogre_lib}" AND EXISTS "${OGRE_LIBRARY_DIRS}/manual-link/") set(prefix "${OGRE_LIBRARY_DIRS}/manual-link/") elseif(ogre_lib MATCHES "Ogre" AND NOT IS_ABSOLUTE "${ogre_lib}") set(prefix "${OGRE_LIBRARY_DIRS}/") From e77122d3b06e1e40bee7bf3e75c51a8e73ef3408 Mon Sep 17 00:00:00 2001 From: Ashton Larkin Date: Thu, 3 Dec 2020 10:53:57 -0500 Subject: [PATCH 43/69] Added build-essential and cmake to packages.apt (#130) Signed-off-by: Ashton Larkin --- .github/ci/packages.apt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/ci/packages.apt b/.github/ci/packages.apt index 6d2c214e..213a0453 100644 --- a/.github/ci/packages.apt +++ b/.github/ci/packages.apt @@ -1 +1,3 @@ +build-essential +cmake pkg-config From ee8bad6153fea9a72ff3d044f452bff3c9808ef9 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Tue, 8 Dec 2020 12:49:15 -0600 Subject: [PATCH 44/69] Prepare for 2.6.0 release (#131) Signed-off-by: Michael Carroll --- CMakeLists.txt | 2 +- Changelog.md | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 43189aa7..67f7e8b5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) #============================================================================ # Initialize the project #============================================================================ -project(ignition-cmake2 VERSION 2.5.0) +project(ignition-cmake2 VERSION 2.6.0) #-------------------------------------- # Initialize the IGNITION_CMAKE_DIR variable with the location of the cmake diff --git a/Changelog.md b/Changelog.md index 7dab7cea..ac125751 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,23 @@ ### Ignition CMake 2.X.X (20XX-XX-XX) +### Ignition CMake 2.6.0 (2020-12-08) + +1. Added build-essential and cmake to packages.apt + * [Pull request 130](https://github.com/ignitionrobotics/ign-cmake/pull/130) + +1. Fix FindIgnOgre on Windows when not using vcpkg + * [Pull request 124](https://github.com/ignitionrobotics/ign-cmake/pull/124) + +1. FindIgnOGRE2: prefer versioned component libraries + * [Pull request 125](https://github.com/ignitionrobotics/ign-cmake/pull/125) + +1. Correct CMake logic and update cpplint to Python3 + * [Pull request 117](https://github.com/ignitionrobotics/ign-cmake/pull/117) + +1. Improve fork experience + * [Pull request 118](https://github.com/ignitionrobotics/ign-cmake/pull/118) + ### Ignition CMake 2.5.0 (2020-09-05) 1. Add additional input directories to parse when generating documentation From 3aec72e6a991173d7744023959db9cda035458d3 Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Thu, 10 Dec 2020 14:03:47 -0800 Subject: [PATCH 45/69] Revert python to optional dependency (#132) Prior to #117, python was an optional dependency; this restores that behavior. * IgnPython: find PythonInterp with QUIET instead of REQUIRED * IgnCodeCheck: skip cpplint if python is not found Signed-off-by: Steve Peters --- cmake/IgnCodeCheck.cmake | 15 +++++++++------ cmake/IgnPython.cmake | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/cmake/IgnCodeCheck.cmake b/cmake/IgnCodeCheck.cmake index 4968898f..636db326 100644 --- a/cmake/IgnCodeCheck.cmake +++ b/cmake/IgnCodeCheck.cmake @@ -40,12 +40,15 @@ function(ign_setup_target_for_codecheck) COMMAND ${CPPCHECK_PATH} ${CPPCHECK_BASE} --enable=missingInclude `${CPPCHECK_FIND}` ) - add_custom_target(cpplint - # cpplint cppcheck - COMMAND ${PYTHON_EXECUTABLE} ${IGNITION_CMAKE_CODECHECK_DIR}/cpplint.py --extensions=cc,hh --quiet `${CPPCHECK_FIND}` - ) - add_custom_target(codecheck - DEPENDS cpplint cppcheck + DEPENDS cppcheck ) + + if(PYTHONINTERP_FOUND) + add_custom_target(cpplint + COMMAND ${PYTHON_EXECUTABLE} ${IGNITION_CMAKE_CODECHECK_DIR}/cpplint.py --extensions=cc,hh --quiet `${CPPCHECK_FIND}` + ) + + add_dependencies(codecheck cpplint) + endif() endfunction() diff --git a/cmake/IgnPython.cmake b/cmake/IgnPython.cmake index a98a7ed5..064f7ea2 100644 --- a/cmake/IgnPython.cmake +++ b/cmake/IgnPython.cmake @@ -22,4 +22,4 @@ if(NOT PYTHON_VERSION) set(PYTHON_VERSION "3") endif() -find_package(PythonInterp ${PYTHON_VERSION} REQUIRED) +find_package(PythonInterp ${PYTHON_VERSION} QUIET) From 70851798b889817f9f063a22b5ea23cc9d992eda Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Thu, 10 Dec 2020 14:35:04 -0800 Subject: [PATCH 46/69] Bump to 2.6.1, update changelog (#133) Signed-off-by: Steve Peters --- CMakeLists.txt | 2 +- Changelog.md | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 67f7e8b5..cbcf0ccc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) #============================================================================ # Initialize the project #============================================================================ -project(ignition-cmake2 VERSION 2.6.0) +project(ignition-cmake2 VERSION 2.6.1) #-------------------------------------- # Initialize the IGNITION_CMAKE_DIR variable with the location of the cmake diff --git a/Changelog.md b/Changelog.md index ac125751..f0f5eec7 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,11 @@ ### Ignition CMake 2.X.X (20XX-XX-XX) +### Ignition CMake 2.6.1 (2020-12-10) + +1. Revert python to optional dependency + * [Pull request 132](https://github.com/ignitionrobotics/ign-cmake/pull/132) + ### Ignition CMake 2.6.0 (2020-12-08) 1. Added build-essential and cmake to packages.apt From 4118be2f06bb173ddef68f7ba0bef88db6e0252b Mon Sep 17 00:00:00 2001 From: Silvio Traversaro Date: Tue, 15 Dec 2020 09:20:50 +0100 Subject: [PATCH 47/69] FindUUID: Always define UUID::UUID on Apple platforms (#128) On Apple platforms, the headers of libuuid and its symbols are provided by the OS SDK, so no further linking is necessary. Fix https://github.com/ignitionrobotics/ign-cmake/issues/127 Signed-off-by: Silvio Traversaro Co-authored-by: Steve Peters --- cmake/FindUUID.cmake | 69 +++++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 30 deletions(-) diff --git a/cmake/FindUUID.cmake b/cmake/FindUUID.cmake index 54246ed2..e28ccfbb 100644 --- a/cmake/FindUUID.cmake +++ b/cmake/FindUUID.cmake @@ -16,42 +16,51 @@ ######################################## # Find uuid if (UNIX) - include(IgnPkgConfig) - ign_pkg_check_modules_quiet(UUID uuid) + if(NOT APPLE) + include(IgnPkgConfig) + ign_pkg_check_modules_quiet(UUID uuid) - if(NOT UUID_FOUND) - include(IgnManualSearch) - ign_manual_search(UUID - HEADER_NAMES "uuid.h" - LIBRARY_NAMES "uuid libuuid" - PATH_SUFFIXES "uuid") - endif() + if(NOT UUID_FOUND) + include(IgnManualSearch) + ign_manual_search(UUID + HEADER_NAMES "uuid.h" + LIBRARY_NAMES "uuid libuuid" + PATH_SUFFIXES "uuid") + endif() - # The pkg-config or the manual search will place - # /include/uuid in INTERFACE_INCLUDE_DIRECTORIES, - # but some projects exepect to use /include, so - # we add it as well. - # See https://github.com/ignitionrobotics/ign-cmake/issues/103 - if(TARGET UUID::UUID) - get_property(uuid_include_dirs - TARGET UUID::UUID - PROPERTY INTERFACE_INCLUDE_DIRECTORIES) + # The pkg-config or the manual search will place + # /include/uuid in INTERFACE_INCLUDE_DIRECTORIES, + # but some projects exepect to use /include, so + # we add it as well. + # See https://github.com/ignitionrobotics/ign-cmake/issues/103 + if(TARGET UUID::UUID) + get_property(uuid_include_dirs + TARGET UUID::UUID + PROPERTY INTERFACE_INCLUDE_DIRECTORIES) - set(uuid_include_dirs_extended ${uuid_include_dirs}) + set(uuid_include_dirs_extended ${uuid_include_dirs}) - foreach(include_dir IN LISTS uuid_include_dirs) - if(include_dir MATCHES "uuid$") - get_filename_component(include_dir_parent ${include_dir} DIRECTORY) - list(APPEND uuid_include_dirs_extended ${include_dir_parent}) - endif() - endforeach() + foreach(include_dir IN LISTS uuid_include_dirs) + if(include_dir MATCHES "uuid$") + get_filename_component(include_dir_parent ${include_dir} DIRECTORY) + list(APPEND uuid_include_dirs_extended ${include_dir_parent}) + endif() + endforeach() - list(REMOVE_DUPLICATES uuid_include_dirs_extended) + list(REMOVE_DUPLICATES uuid_include_dirs_extended) - set_property( - TARGET UUID::UUID - PROPERTY INTERFACE_INCLUDE_DIRECTORIES - ${uuid_include_dirs_extended}) + set_property( + TARGET UUID::UUID + PROPERTY INTERFACE_INCLUDE_DIRECTORIES + ${uuid_include_dirs_extended}) + endif() + else() + # On Apple platforms the UUID library is provided by the OS SDK + # See https://github.com/ignitionrobotics/ign-cmake/issues/127 + set(UUID_FOUND TRUE) + if(NOT TARGET UUID::UUID) + add_library(UUID::UUID INTERFACE IMPORTED) + endif() endif() include(FindPackageHandleStandardArgs) From 9edf0a73ff8ad2abd90d6b8d55111e112ba45403 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Mon, 21 Dec 2020 15:22:20 -0600 Subject: [PATCH 48/69] Remove deprecated doxygen configurations (#136) Signed-off-by: Michael Carroll --- doc/doxygen/api.in | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/doc/doxygen/api.in b/doc/doxygen/api.in index a3f68016..e8fcedd2 100644 --- a/doc/doxygen/api.in +++ b/doc/doxygen/api.in @@ -2109,12 +2109,6 @@ EXTERNAL_GROUPS = YES EXTERNAL_PAGES = YES -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of 'which perl'). -# The default file (with absolute path) is: /usr/bin/perl. - -PERL_PATH = /usr/bin/perl - #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- @@ -2128,15 +2122,6 @@ PERL_PATH = /usr/bin/perl CLASS_DIAGRAMS = NO -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see: -# http://www.mcternan.me.uk/mscgen/)) to produce the chart and insert it in the -# documentation. The MSCGEN_PATH tag allows you to specify the directory where -# the mscgen tool resides. If left empty the tool is assumed to be found in the -# default search path. - -MSCGEN_PATH = - # You can include diagrams made with dia in doxygen documentation. Doxygen will # then run dia to produce the diagram and insert it in the documentation. The # DIA_PATH tag allows you to specify the directory where the dia binary resides. From 3f222bf2f8085a40f16d1fee7e603c7a5559b4cc Mon Sep 17 00:00:00 2001 From: Louise Poubel Date: Tue, 22 Dec 2020 09:21:04 -0800 Subject: [PATCH 49/69] Generate doxygen tutorials for ign-cmake (#137) Signed-off-by: Louise Poubel --- CMakeLists.txt | 9 +++ api.md.in | 10 ++++ tutorials.md.in | 16 ++++++ tutorials/index.md | 6 ++ tutorials/install.md | 130 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 171 insertions(+) create mode 100644 api.md.in create mode 100644 tutorials.md.in create mode 100644 tutorials/index.md create mode 100644 tutorials/install.md diff --git a/CMakeLists.txt b/CMakeLists.txt index cbcf0ccc..0d6c10ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -182,3 +182,12 @@ if (BUILD_TESTING AND BUILDSYSTEM_TESTING) add_subdirectory(examples) endif() + +# Docs +set(IGNITION_CMAKE_DOXYGEN_DIR "${CMAKE_CURRENT_SOURCE_DIR}/doc/doxygen") +configure_file(${CMAKE_SOURCE_DIR}/api.md.in ${CMAKE_BINARY_DIR}/api.md) +configure_file(${CMAKE_SOURCE_DIR}/tutorials.md.in ${CMAKE_BINARY_DIR}/tutorials.md) +ign_create_docs( + API_MAINPAGE_MD "${CMAKE_BINARY_DIR}/api.md" + TUTORIALS_MAINPAGE_MD "${CMAKE_BINARY_DIR}/tutorials.md" + ) diff --git a/api.md.in b/api.md.in new file mode 100644 index 00000000..00f5d6c5 --- /dev/null +++ b/api.md.in @@ -0,0 +1,10 @@ +## Ignition @IGN_DESIGNATION_CAP@ + +Ignition @IGN_DESIGNATION_CAP@ is a component in Ignition, a set of libraries +designed to rapidly develop robot and simulation applications. + +## License + +The code associated with this documentation is licensed under an [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0). + +This documentation is licensed under a [Creative Commons Attribution 4.0 International License](http://creativecommons.org/licenses/by/4.0/). diff --git a/tutorials.md.in b/tutorials.md.in new file mode 100644 index 00000000..7a404d4f --- /dev/null +++ b/tutorials.md.in @@ -0,0 +1,16 @@ +\page tutorials Tutorials + +Welcome to the Ignition @IGN_DESIGNATION_CAP@ tutorials. These tutorials +will guide you through the process of understanding the capabilities of the +Ignition @IGN_DESIGNATION_CAP@ library and how to use the library effectively. + + +**The tutorials** + +1. \subpage install "Installation" + +## License + +The code associated with this documentation is licensed under an [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0). + +This documentation is licensed under a [Creative Commons Attribution 4.0 International License](http://creativecommons.org/licenses/by/4.0/). diff --git a/tutorials/index.md b/tutorials/index.md new file mode 100644 index 00000000..c1fb58bd --- /dev/null +++ b/tutorials/index.md @@ -0,0 +1,6 @@ +# Introduction + +Ignition CMake is a component in the Ignition framework, a set +of libraries designed to rapidly develop robot applications. + +[http://ignitionrobotics.org](http://ignitionrobotics.org) diff --git a/tutorials/install.md b/tutorials/install.md new file mode 100644 index 00000000..6f4c6bd1 --- /dev/null +++ b/tutorials/install.md @@ -0,0 +1,130 @@ +\page install Installation + +# Install + +These instructions are for installing only Ignition CMake. If you're interested +in using all the Ignition libraries, not only Igniton CMake, check out this +[Ignition installation](https://ignitionrobotics.org/docs/latest/install). + +We recommend following the binary install instructions to get up and running as +quickly and painlessly as possible. + +The source install instructions should be used if you need the very latest +software improvements, if you need to modify the code, or if you plan to make a +contribution. + +## Binary Install + +### Ubuntu + +On Ubuntu, it's possible to install Ignition CMake as follows: + +Add OSRF packages: + + echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list + sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys D2486D2DD83DB69272AFE98867170598AF249743 + sudo apt update + +Install Ignition CMake: + + sudo apt install libignition-cmake<#>-dev + +Be sure to replace `<#>` with a number value, such as 1 or 2, depending on +which version you need. + +### macOS + +On macOS, add OSRF packages: + + ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" + brew tap osrf/simulation + +Install Ignition CMake: + + brew install ignition-cmake<#> + +Be sure to replace `<#>` with a number value, such as 1 or 2, depending on +which version you need. + +## Source Install + +### Prerequisites + +#### Ubuntu Bionic 18.04 or above + +Add OSRF packages: + + sudo apt update + sudo apt -y install wget lsb-release gnupg + sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list' + wget http://packages.osrfoundation.org/gazebo.key -O - | apt-key add - + sudo apt-add-repository -s "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -c -s) main" + +Clone source code: + + # This checks out the `main` branch. You can append `-b ign-cmake#` (replace # with a number) to checkout a specific version + git clone http://github.com/ignitionrobotics/ign-cmake + +Install dependencies + + sudo apt -y install $(sort -u $(find . -iname 'packages.apt') | tr '\n' ' ') + +Only on Bionic, update the GCC compiler version: + + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 800 --slave /usr/bin/g++ g++ /usr/bin/g++-8 --slave /usr/bin/gcov gcov /usr/bin/gcov-8 + + +### Building from source + +Build and install as follows: + + cd ign-cmake + mkdir build + cd build + cmake .. + make -j4 + sudo make install + +# Documentation + +API documentation and tutorials can be accessed at +[https://ignitionrobotics.org/libs/cmake](https://ignitionrobotics.org/libs/cmake) + +You can also generate the documentation from a clone of this repository by following these steps. + +1. You will need [Doxygen](http://www.doxygen.org/). On Ubuntu Doxygen can be installed using + + sudo apt-get install doxygen + +2. Clone the repository + + git clone https://github.com/ignitionrobotics/ign-cmake + +3. Configure and build the documentation. + + cd ign-cmake + mkdir build + cd build + cmake .. + make doc + +4. View the documentation by running the following command from the `build` directory. + + firefox doxygen/html/index.html + +# Testing + +Follow these steps to run tests and static code analysis in your clone of this repository. + +1. Follow the [source install instruction](#source-install). + +2. Run tests. + + make test + +3. Static code checker. + + make codecheck + +See the [Writing Tests section of the contributor cmakede](https://ignitionrobotics.org/docs/all/contributing#writing-tests) for help creating or modifying tests. + From aaf3435bb2190586c1b19e34afdf7ad9d0a07fb5 Mon Sep 17 00:00:00 2001 From: Louise Poubel Date: Tue, 22 Dec 2020 11:47:43 -0800 Subject: [PATCH 50/69] Enable make codecheck for ign-cmake (#138) Signed-off-by: Louise Poubel --- CMakeLists.txt | 12 ++++++++++++ examples/CMakeLists.txt | 4 ---- examples/comp_deps/child/include/empty.hh | 16 ++++++++++++++++ examples/comp_deps/parent/include/empty.hh | 16 ++++++++++++++++ examples/use_component_depsA/src/empty.cc | 16 ++++++++++++++++ examples/use_component_depsB/src/empty.cc | 16 ++++++++++++++++ examples/use_component_depsC/src/empty.cc | 16 ++++++++++++++++ 7 files changed, 92 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d6c10ef..d60402b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -183,6 +183,18 @@ if (BUILD_TESTING AND BUILDSYSTEM_TESTING) add_subdirectory(examples) endif() +# Codecheck +set(CPPCHECK_DIRS + ${CMAKE_SOURCE_DIR}/examples +) +set(CPPCHECK_INCLUDE_DIRS + ${CMAKE_SOURCE_DIR}/include + ${CMAKE_SOURCE_DIR}/examples +) +set(IGNITION_CMAKE_CODECHECK_DIR "${CMAKE_CURRENT_SOURCE_DIR}/codecheck") +include(IgnCodeCheck) +ign_setup_target_for_codecheck() + # Docs set(IGNITION_CMAKE_DOXYGEN_DIR "${CMAKE_CURRENT_SOURCE_DIR}/doc/doxygen") configure_file(${CMAKE_SOURCE_DIR}/api.md.in ${CMAKE_BINARY_DIR}/api.md) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 562f8235..7396cb5c 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -23,10 +23,6 @@ if (NOT CMAKE_GENERATOR MATCHES "Visual Studio") ) endif() -# test to see if we have programs necessary to run codecheck -include(IgnCodeCheck) -ign_setup_target_for_codecheck() - foreach(example ${example_directories}) set(run_codecheck false) if (${example} STREQUAL "ign_conf") diff --git a/examples/comp_deps/child/include/empty.hh b/examples/comp_deps/child/include/empty.hh index e69de29b..4e55a3a8 100644 --- a/examples/comp_deps/child/include/empty.hh +++ b/examples/comp_deps/child/include/empty.hh @@ -0,0 +1,16 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ diff --git a/examples/comp_deps/parent/include/empty.hh b/examples/comp_deps/parent/include/empty.hh index e69de29b..4e55a3a8 100644 --- a/examples/comp_deps/parent/include/empty.hh +++ b/examples/comp_deps/parent/include/empty.hh @@ -0,0 +1,16 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ diff --git a/examples/use_component_depsA/src/empty.cc b/examples/use_component_depsA/src/empty.cc index e69de29b..4e55a3a8 100644 --- a/examples/use_component_depsA/src/empty.cc +++ b/examples/use_component_depsA/src/empty.cc @@ -0,0 +1,16 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ diff --git a/examples/use_component_depsB/src/empty.cc b/examples/use_component_depsB/src/empty.cc index e69de29b..4e55a3a8 100644 --- a/examples/use_component_depsB/src/empty.cc +++ b/examples/use_component_depsB/src/empty.cc @@ -0,0 +1,16 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ diff --git a/examples/use_component_depsC/src/empty.cc b/examples/use_component_depsC/src/empty.cc index e69de29b..4e55a3a8 100644 --- a/examples/use_component_depsC/src/empty.cc +++ b/examples/use_component_depsC/src/empty.cc @@ -0,0 +1,16 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ From 07b793fbcbc0f85d76cfef7bbedef82216344271 Mon Sep 17 00:00:00 2001 From: Jose Luis Rivero Date: Wed, 30 Dec 2020 04:32:58 +0100 Subject: [PATCH 51/69] Generate valid visibility macros by avoiding hyphens (#135) Signed-off-by: Jose Luis Rivero Signed-off-by: Louise Poubel --- cmake/IgnUtils.cmake | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cmake/IgnUtils.cmake b/cmake/IgnUtils.cmake index 7fa50221..e40ad141 100644 --- a/cmake/IgnUtils.cmake +++ b/cmake/IgnUtils.cmake @@ -1103,6 +1103,8 @@ function(ign_add_component component_name) # Create an upper case version of the component name, to be used as an export # base name. string(TOUPPER ${component_name} component_name_upper) + # hyphen is not supported as macro name, replace it by underscore + string(REPLACE "-" "_" component_name_upper ${component_name_upper}) #------------------------------------ # Create the target for this component, and configure it to be installed @@ -1349,6 +1351,14 @@ macro(_ign_add_library_or_component) _ign_add_library_or_component_arg_error(EXPORT_BASE) endif() + # check that export_base has no invalid symbols + string(REPLACE "-" "_" export_base_replaced ${export_base}) + if(NOT ${export_base} STREQUAL ${export_base_replaced}) + message(FATAL_ERROR + "export_base has a hyphen which is not" + "supported by macros used for visibility") + endif() + #------------------------------------ # Create the library target From f5e6d3410c0f74708d430b189087738ea508d227 Mon Sep 17 00:00:00 2001 From: Louise Poubel Date: Wed, 30 Dec 2020 10:06:18 -0800 Subject: [PATCH 52/69] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20=202.6.2=20(#142)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Louise Poubel --- CMakeLists.txt | 2 +- Changelog.md | 25 +++++++++++++++++++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d60402b6..78cd1c44 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) #============================================================================ # Initialize the project #============================================================================ -project(ignition-cmake2 VERSION 2.6.1) +project(ignition-cmake2 VERSION 2.6.2) #-------------------------------------- # Initialize the IGNITION_CMAKE_DIR variable with the location of the cmake diff --git a/Changelog.md b/Changelog.md index f0f5eec7..c089ce6f 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,23 @@ ### Ignition CMake 2.X.X (20XX-XX-XX) +### Ignition CMake 2.6.2 (2020-12-29) + +1. FindUUID: Always define UUID::UUID on Apple platforms + * [Pull request 128](https://github.com/ignitionrobotics/ign-cmake/pull/128) + +1. Remove deprecated doxygen configurations + * [Pull request 136](https://github.com/ignitionrobotics/ign-cmake/pull/136) + +1. Generate doxygen tutorials for ign-cmake + * [Pull request 137](https://github.com/ignitionrobotics/ign-cmake/pull/137) + +1. Enable make codecheck for ign-cmake + * [Pull request 138](https://github.com/ignitionrobotics/ign-cmake/pull/138) + +1. Generate valid visibility macros by replacing hyphens in component name + * [Pull request 135](https://github.com/ignitionrobotics/ign-cmake/pull/135) + ### Ignition CMake 2.6.1 (2020-12-10) 1. Revert python to optional dependency @@ -9,19 +26,19 @@ ### Ignition CMake 2.6.0 (2020-12-08) -1. Added build-essential and cmake to packages.apt +1. Added build-essential and cmake to packages.apt * [Pull request 130](https://github.com/ignitionrobotics/ign-cmake/pull/130) 1. Fix FindIgnOgre on Windows when not using vcpkg * [Pull request 124](https://github.com/ignitionrobotics/ign-cmake/pull/124) -1. FindIgnOGRE2: prefer versioned component libraries +1. FindIgnOGRE2: prefer versioned component libraries * [Pull request 125](https://github.com/ignitionrobotics/ign-cmake/pull/125) -1. Correct CMake logic and update cpplint to Python3 +1. Correct CMake logic and update cpplint to Python3 * [Pull request 117](https://github.com/ignitionrobotics/ign-cmake/pull/117) -1. Improve fork experience +1. Improve fork experience * [Pull request 118](https://github.com/ignitionrobotics/ign-cmake/pull/118) ### Ignition CMake 2.5.0 (2020-09-05) From 0d0c81404328539975d4f0843565fa76ebf2e9e0 Mon Sep 17 00:00:00 2001 From: Louise Poubel Date: Tue, 5 Jan 2021 08:42:08 -0800 Subject: [PATCH 53/69] Suppress warning C5205 on Windows (#141) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Louise Poubel Co-authored-by: Carlos Agüero --- include/ignition/utilities/detail/SuppressWarning.hh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/ignition/utilities/detail/SuppressWarning.hh b/include/ignition/utilities/detail/SuppressWarning.hh index d30bb287..f69fb17b 100644 --- a/include/ignition/utilities/detail/SuppressWarning.hh +++ b/include/ignition/utilities/detail/SuppressWarning.hh @@ -124,7 +124,8 @@ #elif defined _MSC_VER #define DETAIL_IGN_UTILS_WARN_IGNORE__NON_VIRTUAL_DESTRUCTOR \ - DETAIL_IGN_UTILS_BEGIN_WARNING_SUPPRESSION(4265) + DETAIL_IGN_UTILS_BEGIN_WARNING_SUPPRESSION(4265) \ + DETAIL_IGN_UTILS_BEGIN_WARNING_SUPPRESSION(5205) #define DETAIL_IGN_UTILS_WARN_RESUME__NON_VIRTUAL_DESTRUCTOR \ DETAIL_IGN_UTILS_WARN_RESUME From 025311086da8cc7f93ffb677392779a9cc894bd2 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Tue, 5 Jan 2021 17:04:20 -0600 Subject: [PATCH 54/69] Make ign-cmake consider hpp files headers as well (#143) Signed-off-by: Michael Carroll --- cmake/IgnUtils.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/IgnUtils.cmake b/cmake/IgnUtils.cmake index e40ad141..b03b8f6f 100644 --- a/cmake/IgnUtils.cmake +++ b/cmake/IgnUtils.cmake @@ -663,7 +663,7 @@ function(ign_install_all_headers) foreach(dir ${directories}) # GLOB all the header files in dir - file(GLOB headers RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${dir}/*.h" "${dir}/*.hh") + file(GLOB headers RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${dir}/*.h" "${dir}/*.hh" "${dir}/*.hpp") list(SORT headers) # Remove the excluded headers From 522e7d438371dabe4b421885dd34ca70247eb45b Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Tue, 12 Jan 2021 09:31:36 -0600 Subject: [PATCH 55/69] Add an option to disable docs when building (#144) Currently we rebuild documentation on every build. This adds an option to disable this (default is enabled). This is helpful for development environments with repeated builds. It can be set via colcon's cmake-args: colcon build --cmake-args -DBUILD_DOCS=OFF Signed-off-by: Michael Carroll --- cmake/IgnCreateDocs.cmake | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmake/IgnCreateDocs.cmake b/cmake/IgnCreateDocs.cmake index a7d69df0..617d9de3 100644 --- a/cmake/IgnCreateDocs.cmake +++ b/cmake/IgnCreateDocs.cmake @@ -47,6 +47,12 @@ function(ign_create_docs) set(oneValueArgs API_MAINPAGE_MD AUTOGENERATED_DOC TUTORIALS_MAINPAGE_MD) set(multiValueArgs "TAGFILES" "ADDITIONAL_INPUT_DIRS") + option(BUILD_DOCS "Build docs" ON) + if (NOT ${BUILD_DOCS}) + message(STATUS "Building Documentation disabled via BUILD_DOCS=OFF") + return() + endif() + #------------------------------------ # Parse the arguments _ign_cmake_parse_arguments(ign_create_docs "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) From 51a91dbf4775c821742f54f80bb2a58272f751d3 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Wed, 13 Jan 2021 08:33:00 -0600 Subject: [PATCH 56/69] Tutorial about developing with cmake and colcon (#145) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Tutorial about developing with cmake and colcon Co-authored-by: Alejandro Hernández Cordero Co-authored-by: Louise Poubel Co-authored-by: Ashton Larkin Signed-off-by: Michael Carroll --- tutorials.md.in | 1 + tutorials/developing_with_ign-cmake.md | 272 +++++++++++++++++++++++++ 2 files changed, 273 insertions(+) create mode 100644 tutorials/developing_with_ign-cmake.md diff --git a/tutorials.md.in b/tutorials.md.in index 7a404d4f..9bef8001 100644 --- a/tutorials.md.in +++ b/tutorials.md.in @@ -8,6 +8,7 @@ Ignition @IGN_DESIGNATION_CAP@ library and how to use the library effectively. **The tutorials** 1. \subpage install "Installation" +1. \subpage developingwithcmake "Developing with Ignition CMake" ## License diff --git a/tutorials/developing_with_ign-cmake.md b/tutorials/developing_with_ign-cmake.md new file mode 100644 index 00000000..25704c0e --- /dev/null +++ b/tutorials/developing_with_ign-cmake.md @@ -0,0 +1,272 @@ +\page developingwithcmake Developing with Ignition CMake + +# Developing with Ignition CMake + +This tutorial documents various tips and strategies for developing with Ignition CMake. + +## Helpful CMake flags + +There are several flags that control the results of the CMake tool. +Some of these flags are built into CMake, where some are Ignition CMake specific. + +All of the following flags may be set as part of an individual CMake invocation. +Alternatively, the flags may be passed to `colcon` using techniques described later in this document. + +### Setting the build type + +The `CMAKE_BUILD_TYPE` variable controls the type of binary output from the build stage. +This will have an impact on the flags passed to the compiler and linker. + +The available options are: + +* `RelWithDebInfo`: Mostly optimized build, but with debug symbols. +* `Debug`: Debug build without optimizations, with debug symbols enabled. +* `Release`: Fully optimized build, no debug symbols. +* `MinSizeRel`: Fully optimized build, minimal binary size +* `Coverage`: Build with additional information required for the [`gcov` analysis tool](https://en.wikipedia.org/wiki/Gcov) +* `Profile`: Use flags that are helpful with the [`gprof` profiling tool](https://en.wikipedia.org/wiki/Gprof) + +More information about flags applied can be found in [IgnSetCompilerFlags.cmake](https://github.com/ignitionrobotics/ign-cmake/blob/ign-cmake2/cmake/IgnSetCompilerFlags.cmake) + +If left unspecified, `CMAKE_BUILD_TYPE` is set to `RelWithDebInfo` + +To change the build type, set the CMake flag: + +``` +-DCMAKE_BUILD_TYPE=Debug +``` + +### Creating a compilation database + +`CMake` can optionally generate a compilation data base that may be used with a variety of code completion tools. + +By default, a compilation database is *not generated* + +To enable compilation database generation, set the CMake flag: + +``` +-DCMAKE_EXPORT_COMPILE_COMMANDS=ON +``` + +For more information about what the compilation database is, consult the [`clang` documentation](https://clang.llvm.org/docs/JSONCompilationDatabase.html) + +Some examples of utilities that can use the compilation database: + +* [`coc.vim`](https://github.com/neoclide/coc.nvim): Code completion for VIM +* [`YouCompleteMe`](https://github.com/ycm-core/YouCompleteMe) Code completion for VIM + +### Using the ninja build system + +Rather than using `make`, it may be desired to use the [Ninja](https://ninja-build.org/) build tool. + +By default `make` will be used. + +To change the build system type, set the CMake flag: + +``` +-GNinja +``` + +### Address sanitizer (ASan) + +The `gcc` and `clang` compilers have a set of flags to generate instrumented builds for detecting memory leaks. + +By default, address sanitizer is *not used*. + +To enable address sanitizer, set all of the following flags: + +``` +-DCMAKE_CXX_FLAGS="-fsanitize=address -fsanitize=leak -g" +-DCMAKE_C_FLAGS="-fsanitize=address -fsanitize=leak -g" +-DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address -fsanitize=leak" +-DCMAKE_MODULE_LINKER_FLAGS="-fsanitize=address -fsanitize=leak" +``` + +This will report if memory is leaked during execution of binaries or tests. + +More information about address santizier can be found in the [ASan documentation](https://github.com/google/sanitizers/wiki/AddressSanitizer). + +Note: Address sanitizer may have an impact on the performance of execution. + +### Using CCache + +When you are doing frequent rebuilds, you can use a program to cache intermediate compiler results. + +First, install [`ccache`](https://ccache.dev/) and configure it to an appropriate cache size for your system: + +``` +$ sudo apt update && sudo apt install ccache +$ ccache -M10G +Set cache size limit to 10.0 GB +``` + +Then set the CMake flags: + +``` +-DCMAKE_C_COMPILER_LAUNCHER=ccache +-DCMAKE_CXX_COMPILER_LAUNCHER=ccache +``` + +### Enabling/Disabling Documentation + +When you are doing frequent rebuilds, it generally doesn't make sense to rebuild documentation each build. + +By default, building documentation is *enabled*. + +To disable building documentation, set the CMake flag: + +``` +-DBUILD_DOCS=OFF +``` + +### Enabling/Disabling Tests + +If your intent is to only produce libraries and executables, it is possible to disables tests. + +By default, building tests is *enabled*. + +To disable building tests, set the CMake flag: + +``` +-DBUILD_TESTING=OFF +``` + +### Enabling/Disabling Buildsystem Tests + +There are additional tests of the Ignition CMake buildsystem. +It is recommend to run these tests when making modifications to the Ignition CMake codebase. + +By default, building buildsystem tests is *disabled*. + +To enable building buildsystem tests, set the CMake flags: + +``` +-DBUILD_TESTING=ON +-DBUILDSYSTEM_TESTING=ON +``` + +## Developing with Colcon and vcstool + +[`colcon`](https://colcon.readthedocs.io/en/released/) is a tool that improves the workflow of building and testing multiple software packages. +As an Ignition collection is composed of multiple packages that are frequently built and tested together, `colcon` eases this workflow. + +The basic outline of obtaining Ignition source packages via `vcs` and building with `colcon` is available in the [Ignition source installation documentation](https://ignitionrobotics.org/docs/latest/install_ubuntu_src). + +### Passing CMake flags via command line + +When performing `colcon` builds, flags may be passed to Ignition CMake to configure the build. + +This can be done via the `--cmake-args` flag in `colcon`: + +``` +colcon build --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=1 +``` + +### Passing colcon mixins via command line + +To ease configuration of common flags, `colcon` has a concept of `mixins`, that are flags that "shortcut" groups of behavior. + +The set of readily-available defaults is in the [colcon-mixin-repository](https://github.com/colcon/colcon-mixin-repository). + +To install: + +``` +$ colcon mixin add default https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml +$ colcon mixin update default +$ colcon mixin show +``` + +An example of building with `colcon` with two mixins: + * [`ccache` mixin](https://github.com/colcon/colcon-mixin-repository/blob/master/ccache.mixin) + * [`rel-with-db-info` mixin](https://github.com/colcon/colcon-mixin-repository/blob/master/build-type.mixin) + +``` +colcon build --mixin ccache rel-with-deb-info +``` + +This will build with the flags applied from the requested mixins. + +Colcon allows you to create your own mixins for commonly-reused command line flags. +For more information about creating mixins, consult the [`colcon mixin` documentation](https://colcon.readthedocs.io/en/released/reference/mixin-arguments.html) + +### Using a defaults file + +It is useful to be able to apply a consistent set of flags across an entire Ignition collection when building. +One mechanism for accomplishing this is a `defaults.yaml` file. +This is a file of configuration options that `colcon` will read to customize the default behavior. +More information about the `defaults.yaml` file can be found in the corresponding [`colcon` documentation](https://colcon.readthedocs.io/en/released/user/configuration.html#defaults-yaml) + +For the following, if you do not have `colcon` or `vcs` installed, consult the [Ignition source installation documentation](https://ignitionrobotics.org/docs/latest/install_ubuntu_src). + +To try this out, first create an Ignition source workspace: +``` +mkdir -p ~/ign_edifice/src +cd ~/ign_edifice/ +wget https://raw.githubusercontent.com/ignition-tooling/gazebodistro/master/collection-edifice.yaml +vcs import src < collection-edifice.yaml +``` + +Then add a `~/ign_edifice/defaults.yaml` file with compilation flags: + +``` +{ + "build": { + "merge-install": true, + "symlink-install": true, + "cmake-args": [ + "--no-warn-unused-cli", + "-DCMAKE_EXPORT_COMPILE_COMMANDS=1", + "-DCMAKE_BUILD_TYPE=RelWithDebInfo", + ] + } +} +``` + +To build with this defaults file, first export the correct environment variable and execute colcon: + +``` +cd ~/ign_edifice +export COLCON_DEFAULTS_FILE=`pwd`/defaults.yaml +colcon build +``` + +### Using a defaults file with mixins + +Mixins can also be applied via the `defaults.yaml` file: + +``` +{ + "build": { + "merge-install": true, + "symlink-install": true, + "mixins": [ + "compile-commands", + "rel-with-deb-info", + ] + } +} +``` + +### Setting a per-workspace defaults file with direnv + +Optionally, defaults can be applied user-wide by placing a defaults file at `$COLCON_HOME/defaults.yaml` (which is `~/.colcon/defaults.yaml` by default). + +In order to manage per-workspace settings, a tool like [`direnv`](https://direnv.net/) can be used to automate the application of the environment variable. +Once `direnv` is installed and configured with your shell of choice, do the following: + +``` +$ cd ~/ign_edifice/ +# The environment variable will be unset +$ echo $COLCON_DEFAULTS_FILE + +$ echo export COLCON_DEFAULTS_FILE=`pwd`/defaults.yaml > .envrc +direnv: error .envrc is blocked, Run `direnv allow` to approve its content +$ direnv allow +direnv: loading ~/ign_edifice/.envrc +direnv: export +COLCON_DEFAULTS_FILE + +$ echo $COLCON_DEFAULTS_FILE +~/ign_edifice/defaults.yaml +``` + +Once this is configured, the environment will be applied each time you navigate to the `~/ign_edifice` directory or its children. From bed3f7b2b2d0210b35808b2cfa17026169f7c4b4 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Fri, 15 Jan 2021 19:40:30 -0600 Subject: [PATCH 57/69] Set CMake's CMP0079 policy (#146) Signed-off-by: Michael Carroll Co-authored-by: Ashton Larkin <42042756+adlarkin@users.noreply.github.com> Co-authored-by: Ashton Larkin <42042756+adlarkin@users.noreply.github.com> --- cmake/IgnUtils.cmake | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmake/IgnUtils.cmake b/cmake/IgnUtils.cmake index b03b8f6f..f9e80376 100644 --- a/cmake/IgnUtils.cmake +++ b/cmake/IgnUtils.cmake @@ -1072,6 +1072,10 @@ function(ign_add_component component_name) # Parse the arguments cmake_parse_arguments(ign_add_component "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + if(POLICY CMP0079) + cmake_policy(SET CMP0079 NEW) + endif() + if(ign_add_component_SOURCES) set(sources ${ign_add_component_SOURCES}) elseif(NOT ign_add_component_INTERFACE) @@ -1250,7 +1254,6 @@ function(ign_add_component component_name) set_property(TARGET ${PROJECT_LIBRARY_TARGET_NAME}-all PROPERTY INTERFACE_IGN_ALL_KNOWN_COMPONENTS "${all_known_components};${component_target_name}") endif() - endfunction() ################################################# From f78d69e8c5aebdfbaf71bee28e18f932fdeaef4b Mon Sep 17 00:00:00 2001 From: Mabel Zhang Date: Wed, 20 Jan 2021 20:34:21 -0500 Subject: [PATCH 58/69] Windows installation via conda-forge (#139) Signed-off-by: Mabel Zhang Co-authored-by: John Shepherd --- README.md | 34 ++----- tutorials/install.md | 224 +++++++++++++++++++++++++++++++++---------- 2 files changed, 182 insertions(+), 76 deletions(-) diff --git a/README.md b/README.md index ed1c6c97..f0e476c3 100644 --- a/README.md +++ b/README.md @@ -18,11 +18,11 @@ Windows | [![Build Status](https://build.osrfoundation.org/buildStatus/ico [Features](#features) -[Install](#install) +[Installation](#install) -* [Binary Install](#binary-install) +* [Binary Installation](#binary-install) -* [Source Install](#source-install) +* [Source Installation](#source-install) * [Prerequisites](#prerequisites) @@ -30,10 +30,6 @@ Windows | [![Build Status](https://build.osrfoundation.org/buildStatus/ico [Usage](#usage) -[Documentation](#documentation) - -[Testing](#testing) - [Folder Structure](#folder-structure) [Code of Conduct](#code-of-conduct) @@ -52,11 +48,11 @@ These modules are tailored to the ignition projects, so their use for non-igniti # Install -We recommend following the [Binary Install](#binary-install) instructions to get up and running as quickly and painlessly as possible. +We recommend following the [Binary Installation](#binary-install) instructions to get up and running as quickly and painlessly as possible. -The [Source Install](#source-install) instructions should be used if you need the very latest software improvements, you need to modify the code, or you plan to make a contribution. +The [Source Installation](#source-install) instructions should be used if you need the very latest software improvements, you need to modify the code, or you plan to make a contribution. -## Binary Install +## Binary Installation On Ubuntu systems, `apt-get` can be used to install `ignition-cmake`: @@ -66,7 +62,7 @@ $ sudo apt install libignition-cmake<#>-dev Be sure to replace `<#>` with a number value, such as `1` or `2`, depending on which version you need. -## Source Install +## Source Installation ### Prerequisites @@ -76,7 +72,7 @@ The only prerequisite of `ignition-cmake` is `cmake`. Ubuntu users can install c $ sudo apt install cmake ``` -### Building from source +### Building from Source To build and install from source, you can clone the repo and use cmake to install the modules as though this is a regular cmake project: @@ -96,20 +92,6 @@ Replace `/path/to/install/dir` to whatever directory you want to install this pa This library is used internally by the ignition projects. See other ignition projects for examples of how this gets used. -# Documentation - -Documentation for `ignition-cmake` can be found within the source code, and also in the [MIGRATION.md guide](https://github.com/ignitionrobotics/ign-cmake/blob/master/MIGRATION.md). - -# Testing - -A fuller suite of tests in the `examples` directory can be enabled by building with `BUILDSYSTEM_TESTING` enabled. -Tests can be run by building the `test` target. From your build directory you can run: - -``` -$ cmake .. -DBUILDSYSTEM_TESTING=1 -$ make test -``` - # Folder Structure * `cmake`: cmake modules that get installed by this package diff --git a/tutorials/install.md b/tutorials/install.md index 6f4c6bd1..2f5645bd 100644 --- a/tutorials/install.md +++ b/tutorials/install.md @@ -1,7 +1,5 @@ \page install Installation -# Install - These instructions are for installing only Ignition CMake. If you're interested in using all the Ignition libraries, not only Igniton CMake, check out this [Ignition installation](https://ignitionrobotics.org/docs/latest/install). @@ -13,77 +11,185 @@ The source install instructions should be used if you need the very latest software improvements, if you need to modify the code, or if you plan to make a contribution. -## Binary Install +# Binary Install -### Ubuntu +## Ubuntu On Ubuntu, it's possible to install Ignition CMake as follows: Add OSRF packages: - - echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list - sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys D2486D2DD83DB69272AFE98867170598AF249743 - sudo apt update + ``` + echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list + sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys D2486D2DD83DB69272AFE98867170598AF249743 + sudo apt update + ``` Install Ignition CMake: - - sudo apt install libignition-cmake<#>-dev + ``` + sudo apt install libignition-cmake<#>-dev + ``` Be sure to replace `<#>` with a number value, such as 1 or 2, depending on which version you need. -### macOS +## macOS On macOS, add OSRF packages: - - ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" - brew tap osrf/simulation + ``` + ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" + brew tap osrf/simulation + ``` Install Ignition CMake: - - brew install ignition-cmake<#> + ``` + brew install ignition-cmake<#> + ``` Be sure to replace `<#>` with a number value, such as 1 or 2, depending on which version you need. -## Source Install +## Windows -### Prerequisites +Install [Conda package management system](https://docs.conda.io/projects/conda/en/latest/user-guide/install/download.html). +Miniconda suffices. + +Open a Visual Studio Command Prompt (search for "x64 Native Tools Command Prompt for VS 2019" in the Windows search near the Start button). +Optionally, right-click and pin to the task bar for quick access in the future. + +If you did not add Conda to your `PATH` environment variable during Conda installation, you may need to navigate to the location of `condabin` in order to use the `conda` command. +To find `condabin`, search for "Anaconda Prompt" in the Windows search near the Start button, open it, run `where conda`, and look for a line containing the directory `condabin`. + +1. Navigate to your `condabin` if necessary, and then create and activate a Conda environment: + ``` + conda create -n ign-ws + conda activate ign-ws + ``` + + Once you have activated an environment, a prefix like `(ign-ws)` will be prepended to your prompt, and you can use the `conda` command outside of `condabin`. + + You can use `conda info --envs` to see all your environments. -#### Ubuntu Bionic 18.04 or above + To remove an environment, use `conda env remove --name `. + +2. Install Ignition CMake: + ``` + conda install libignition-cmake<#> --channel conda-forge + ``` + + Be sure to replace `<#>` with a number value, such as 1 or 2, depending on which version you need. + + You can view all the versions with + ``` + conda search libignition-cmake* --channel conda-forge + ``` + + and view their dependencies with + ``` + conda search libignition-cmake* --channel conda-forge --info + ``` + + and install a specific minor version with + ``` + conda install libignition-cmake=2.6.1 --channel conda-forge + ``` + +# Source Install + +## Ubuntu Bionic 18.04 or above + +### Prerequisites Add OSRF packages: +``` +sudo apt update +sudo apt -y install wget lsb-release gnupg +sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list' +wget http://packages.osrfoundation.org/gazebo.key -O - | apt-key add - +sudo apt-add-repository -s "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -c -s) main" +``` - sudo apt update - sudo apt -y install wget lsb-release gnupg - sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list' - wget http://packages.osrfoundation.org/gazebo.key -O - | apt-key add - - sudo apt-add-repository -s "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -c -s) main" +Only on Bionic, update the GCC compiler version: +``` +sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 800 --slave /usr/bin/g++ g++ /usr/bin/g++-8 --slave /usr/bin/gcov gcov /usr/bin/gcov-8 +``` + +### Building from source Clone source code: - # This checks out the `main` branch. You can append `-b ign-cmake#` (replace # with a number) to checkout a specific version - git clone http://github.com/ignitionrobotics/ign-cmake +``` +# This checks out the `main` branch. You can append `-b ign-cmake#` (replace # with a number) to checkout a specific version +git clone http://github.com/ignitionrobotics/ign-cmake +``` Install dependencies +``` +sudo apt -y install $(sort -u $(find . -iname 'packages.apt') | tr '\n' ' ') +``` - sudo apt -y install $(sort -u $(find . -iname 'packages.apt') | tr '\n' ' ') +Build and install as follows: +``` +cd ign-cmake +mkdir build +cd build +cmake .. +make -j4 +sudo make install +``` -Only on Bionic, update the GCC compiler version: +## Windows 10 + +### Prerequisites - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 800 --slave /usr/bin/g++ g++ /usr/bin/g++-8 --slave /usr/bin/gcov gcov /usr/bin/gcov-8 +1. Install [Conda package management system](https://docs.conda.io/projects/conda/en/latest/user-guide/install/download.html). + Miniconda suffices. +2. Install [Visual Studio 2019](https://visualstudio.microsoft.com/downloads/). + The Community version is free for students, open-source contributors, and individuals. + Check "Desktop development with C++" in the "Workloads" tab, and uncheck "C++ CMake Tools". We will install `cmake` via Conda. ### Building from source -Build and install as follows: +Open a Visual Studio Command Prompt (search for "x64 Native Tools Command Prompt for VS 2019" in the search field near the Windows button). +Optionally, right-click and pin to the task bar for quick access in the future. + +If you did not add Conda to your `PATH` environment variable during Conda installation, you may need to navigate to the location of `condabin` in order to use the `conda` command. +To find `condabin`, search for "Anaconda Prompt" in the search field near the Windows button, open it, run `where conda`, and look for a line containing the directory `condabin`. + +1. Navigate to your `condabin` if necessary, and then create and activate a Conda environment: + ``` + conda create -n ign-ws + conda activate ign-ws + ``` + + Once you have activated an environment, a prefix like `(ign-ws)` will be prepended to your prompt, and you can use the `conda` command outside of `condabin`. - cd ign-cmake - mkdir build - cd build - cmake .. - make -j4 - sudo make install + You can use `conda info --envs` to see all your environments. + + To remove an environment, use `conda env remove --name `. + +2. Install dependencies + ``` + conda install git cmake pkg-config --channel conda-forge + ``` + +3. Navigate to where you would like to build the library, and then clone the repository. + ``` + # Optionally, append `-b ign-cmake#` (replace # with a number) to check out a specific version + git clone https://github.com/ignitionrobotics/ign-cmake.git + ``` + +4. Build. + ``` + cd ign-cmake + mkdir build + cd build + cmake .. # Optionally, -DCMAKE_INSTALL_PREFIX=path\to\install + cmake --build . --config Release + cmake --install . --config Release + ``` + +**Note** If you find that the build is failing due to failures in the `test` directory, then you may need to disable tests by adding `-DBUILD_TESTING=OFF` to the `cmake ..` command. # Documentation @@ -93,24 +199,31 @@ API documentation and tutorials can be accessed at You can also generate the documentation from a clone of this repository by following these steps. 1. You will need [Doxygen](http://www.doxygen.org/). On Ubuntu Doxygen can be installed using - - sudo apt-get install doxygen + ``` + sudo apt-get install doxygen + ``` 2. Clone the repository - git clone https://github.com/ignitionrobotics/ign-cmake + ``` + git clone https://github.com/ignitionrobotics/ign-cmake + ``` 3. Configure and build the documentation. - - cd ign-cmake - mkdir build - cd build - cmake .. - make doc + ``` + cd ign-cmake + mkdir build + cd build + cmake .. + make doc + ``` 4. View the documentation by running the following command from the `build` directory. + ``` + firefox doxygen/html/index.html + ``` - firefox doxygen/html/index.html +**Note** Alternatively, documentation for `ignition-cmake` can be found within the source code, and also in the [MIGRATION.md guide](https://github.com/ignitionrobotics/ign-cmake/blob/master/MIGRATION.md). # Testing @@ -119,12 +232,23 @@ Follow these steps to run tests and static code analysis in your clone of this r 1. Follow the [source install instruction](#source-install). 2. Run tests. - - make test + ``` + make test + ``` 3. Static code checker. + ``` + make codecheck + ``` + +Additionally, a fuller suite of tests in the `examples` directory can be enabled by building with `BUILDSYSTEM_TESTING` enabled. +Tests can be run by building the `test` target. From your build directory you can run: + +``` +$ cmake .. -DBUILDSYSTEM_TESTING=1 +$ make test +``` - make codecheck -See the [Writing Tests section of the contributor cmakede](https://ignitionrobotics.org/docs/all/contributing#writing-tests) for help creating or modifying tests. +See the [Writing Tests section of the ign-cmake contributor documentation](https://ignitionrobotics.org/docs/all/contributing#writing-tests) for help creating or modifying tests. From b03ca34191e538d334f8d9bb285711a4b487e2a4 Mon Sep 17 00:00:00 2001 From: Stefan Profanter Date: Thu, 4 Feb 2021 18:32:02 +0100 Subject: [PATCH 59/69] Ensure relocatable config files (#129) * fix: Use PACKAGE_PREFIX_DIR to ensure relocatable CMake install for conan Signed-off-by: Stefan Profanter * Compute ignition .pc file relative path to prefix * Compute path to prefix for ignition-cmake.pc Signed-off-by: Steve Peters Co-authored-by: Louise Poubel Co-authored-by: Steve Peters Co-authored-by: Jose Luis Rivero --- CMakeLists.txt | 8 +++++++- cmake/IgnPackaging.cmake | 8 +++++++- cmake/ignition-config.cmake.in | 2 +- cmake/pkgconfig/ignition-component.pc.in | 2 +- cmake/pkgconfig/ignition.pc.in | 2 +- config/ignition-cmake.pc.in | 2 +- 6 files changed, 18 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 78cd1c44..3c4baae5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,6 +56,7 @@ set(ign_version_output "${PROJECT_NAME_LOWER}-config-version.cmake") set(ign_config_install_dir "${CMAKE_INSTALL_DATAROOTDIR}/cmake/${PROJECT_NAME_LOWER}") set(ign_pkgconfig_input "${CMAKE_CURRENT_SOURCE_DIR}/config/ignition-cmake.pc.in") set(ign_pkgconfig_output "${CMAKE_BINARY_DIR}/ignition-cmake${PROJECT_VERSION_MAJOR}.pc") +set(ign_pkgconfig_install_dir "${IGN_LIB_INSTALL_DIR}/pkgconfig") set(ign_utilities_target ${PROJECT_EXPORT_NAME}-utilities) set(ign_utilities_import_target_name ${PROJECT_EXPORT_NAME}::${ign_utilities_target}) set(ign_utilities_target_output_filename "${ign_utilities_target}-targets.cmake") @@ -86,11 +87,16 @@ install( #-------------------------------------- # Configure and install the pkgconfig file (needed for utilities headers) +file(RELATIVE_PATH + IGN_PC_CONFIG_RELATIVE_PATH_TO_PREFIX + "${CMAKE_INSTALL_PREFIX}/${ign_pkgconfig_install_dir}" + "${CMAKE_INSTALL_PREFIX}" +) configure_file(${ign_pkgconfig_input} ${ign_pkgconfig_output} @ONLY) install( FILES ${ign_pkgconfig_output} - DESTINATION ${IGN_LIB_INSTALL_DIR}/pkgconfig + DESTINATION ${ign_pkgconfig_install_dir} COMPONENT pkgconfig) #============================================================================ diff --git a/cmake/IgnPackaging.cmake b/cmake/IgnPackaging.cmake index 907a04b9..4ee9e2d4 100644 --- a/cmake/IgnPackaging.cmake +++ b/cmake/IgnPackaging.cmake @@ -198,12 +198,18 @@ function(_ign_create_pkgconfig) endif() set(pkgconfig_output "${CMAKE_BINARY_DIR}/cmake/pkgconfig/${target_name}.pc") + set(pkgconfig_install_dir "${IGN_LIB_INSTALL_DIR}/pkgconfig") + file(RELATIVE_PATH + PC_CONFIG_RELATIVE_PATH_TO_PREFIX + "${CMAKE_INSTALL_PREFIX}/${pkgconfig_install_dir}" + "${CMAKE_INSTALL_PREFIX}" + ) configure_file(${pkgconfig_input} ${pkgconfig_output} @ONLY) install( FILES ${pkgconfig_output} - DESTINATION ${IGN_LIB_INSTALL_DIR}/pkgconfig + DESTINATION ${pkgconfig_install_dir} COMPONENT pkgconfig) endfunction() diff --git a/cmake/ignition-config.cmake.in b/cmake/ignition-config.cmake.in index df7c9fc1..7bd502fb 100644 --- a/cmake/ignition-config.cmake.in +++ b/cmake/ignition-config.cmake.in @@ -179,7 +179,7 @@ foreach(component ${@PKG_NAME@_FIND_COMPONENTS}) endforeach() # Specify the doxygen tag file -set(@PROJECT_NAME_NO_VERSION_UPPER@_DOXYGEN_TAGFILE "@CMAKE_INSTALL_PREFIX@/@IGN_DATA_INSTALL_DIR@/@PROJECT_NAME_LOWER@.tag.xml") +set(@PROJECT_NAME_NO_VERSION_UPPER@_DOXYGEN_TAGFILE "${PACKAGE_PREFIX_DIR}/@IGN_DATA_INSTALL_DIR@/@PROJECT_NAME_LOWER@.tag.xml") # Specify the API url. This is where the doxygen tag file will resolve URLS to. set(@PROJECT_NAME_NO_VERSION_UPPER@_API_URL "https://ignitionrobotics.org/api/@IGN_DESIGNATION@/@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@") diff --git a/cmake/pkgconfig/ignition-component.pc.in b/cmake/pkgconfig/ignition-component.pc.in index 9837dee6..b542f394 100644 --- a/cmake/pkgconfig/ignition-component.pc.in +++ b/cmake/pkgconfig/ignition-component.pc.in @@ -1,4 +1,4 @@ -prefix=@CMAKE_INSTALL_PREFIX@ +prefix=${pcfiledir}/@PC_CONFIG_RELATIVE_PATH_TO_PREFIX@ libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@/ignition/@IGN_DESIGNATION@@PROJECT_VERSION_MAJOR@ diff --git a/cmake/pkgconfig/ignition.pc.in b/cmake/pkgconfig/ignition.pc.in index e2ee6c3f..d1cace02 100644 --- a/cmake/pkgconfig/ignition.pc.in +++ b/cmake/pkgconfig/ignition.pc.in @@ -1,4 +1,4 @@ -prefix=@CMAKE_INSTALL_PREFIX@ +prefix=${pcfiledir}/@PC_CONFIG_RELATIVE_PATH_TO_PREFIX@ libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@/ignition/@IGN_DESIGNATION@@PROJECT_VERSION_MAJOR@ diff --git a/config/ignition-cmake.pc.in b/config/ignition-cmake.pc.in index 63e18137..ff8a8973 100644 --- a/config/ignition-cmake.pc.in +++ b/config/ignition-cmake.pc.in @@ -1,4 +1,4 @@ -prefix=@CMAKE_INSTALL_PREFIX@ +prefix=${pcfiledir}/@IGN_PC_CONFIG_RELATIVE_PATH_TO_PREFIX@ includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@/ignition/@IGN_DESIGNATION@@PROJECT_VERSION_MAJOR@ Name: Ignition @IGN_DESIGNATION@ From f1506194219509502ef7e0c77b0f640acf58d036 Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Thu, 4 Feb 2021 13:49:18 -0800 Subject: [PATCH 60/69] Bump to 2.7.0~pre1 (#147) Signed-off-by: Steve Peters --- CMakeLists.txt | 4 ++-- Changelog.md | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c4baae5..0806e196 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) #============================================================================ # Initialize the project #============================================================================ -project(ignition-cmake2 VERSION 2.6.2) +project(ignition-cmake2 VERSION 2.7.0) #-------------------------------------- # Initialize the IGNITION_CMAKE_DIR variable with the location of the cmake @@ -20,7 +20,7 @@ include(IgnCMake) #-------------------------------------- # Set up the project -ign_configure_project() +ign_configure_project(VERSION_SUFFIX pre1) #-------------------------------------- # Set project-specific options diff --git a/Changelog.md b/Changelog.md index c089ce6f..bbf13902 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,29 @@ ### Ignition CMake 2.X.X (20XX-XX-XX) +### Ignition CMake 2.7.0 (2021-XX-XX) + +1. Set cmake CMP0079 policy + * [Pull request 146](https://github.com/ignitionrobotics/ign-cmake/pull/146) + +1. Tutorial about building with cmake and colcon + * [Pull request 145](https://github.com/ignitionrobotics/ign-cmake/pull/145) + +1. Add an option to disable docs when building + * [Pull request 144](https://github.com/ignitionrobotics/ign-cmake/pull/144) + +1. Install hpp files as headers + * [Pull request 143](https://github.com/ignitionrobotics/ign-cmake/pull/143) + +1. Suppress warning C5205 on Windows + * [Pull request 141](https://github.com/ignitionrobotics/ign-cmake/pull/141) + +1. Windows installation instructions via conda-forge + * [Pull request 139](https://github.com/ignitionrobotics/ign-cmake/pull/139) + +1. Ensure relocatable config files + * [Pull request 129](https://github.com/ignitionrobotics/ign-cmake/pull/129) + ### Ignition CMake 2.6.2 (2020-12-29) 1. FindUUID: Always define UUID::UUID on Apple platforms From e49e95b9345739654c936d04e314a51de9adbc31 Mon Sep 17 00:00:00 2001 From: Jenn Nguyen Date: Thu, 4 Feb 2021 18:16:28 -0800 Subject: [PATCH 61/69] Added issue & PR templates (#148) Signed-off-by: Jenn Nguyen --- .github/ISSUE_TEMPLATE/bug_report.md | 29 +++++++++++++ .github/ISSUE_TEMPLATE/feature_request.md | 23 ++++++++++ .github/PULL_REQUEST_TEMPLATE.md | 52 +++++++++++++++++++++++ .github/PULL_REQUEST_TEMPLATE/port.md | 6 +++ 4 files changed, 110 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/PULL_REQUEST_TEMPLATE/port.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000..3d89f641 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,29 @@ +--- +name: Bug report +about: Report a bug +labels: bug +--- + + + +## Environment +* OS Version: +* Source or binary build? + + + +## Description +* Expected behavior: +* Actual behavior: + +## Steps to reproduce + + +1. +2. +3. + +## Output + diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 00000000..f49727a0 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,23 @@ +--- +name: Feature request +about: Request a new feature +labels: enhancement +--- + + + +## Desired behavior + + +## Alternatives considered + + +## Implementation suggestion + + +## Additional context + diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..6c88bd54 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,52 @@ + + +# Bug Report + +Fixes issue # + +## Summary + + +## Checklist +- [ ] Signed all commits for DCO +- [ ] Added tests +- [ ] Updated documentation (as needed) +- [ ] Updated migration guide (as needed) +- [ ] `codecheck` passed (See + [contributing](https://ignitionrobotics.org/docs/all/contributing#contributing-code)) +- [ ] All tests passed (See + [test coverage](https://ignitionrobotics.org/docs/all/contributing#test-coverage)) +- [ ] While waiting for a review on your PR, please help review +[another open pull request](https://github.com/pulls?q=is%3Aopen+is%3Apr+user%3Aignitionrobotics+archived%3Afalse+) +to support the maintainers + +**Note to maintainers**: Remember to use **Squash-Merge** + +--- + +# New feature + +Closes # + +## Summary + + +## Test it + + +## Checklist +- [ ] Signed all commits for DCO +- [ ] Added tests +- [ ] Added example world and/or tutorial +- [ ] Updated documentation (as needed) +- [ ] Updated migration guide (as needed) +- [ ] `codecheck` passed (See [contributing](https://ignitionrobotics.org/docs/all/contributing#contributing-code)) +- [ ] All tests passed (See [test coverage](https://ignitionrobotics.org/docs/all/contributing#test-coverage)) +- [ ] While waiting for a review on your PR, please help review +[another open pull request](https://github.com/pulls?q=is%3Aopen+is%3Apr+user%3Aignitionrobotics+archived%3Afalse+) +to support the maintainers + +**Note to maintainers**: Remember to use **Squash-Merge** diff --git a/.github/PULL_REQUEST_TEMPLATE/port.md b/.github/PULL_REQUEST_TEMPLATE/port.md new file mode 100644 index 00000000..6066e894 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE/port.md @@ -0,0 +1,6 @@ +Port to + +Branch comparison: https://github.com/ignitionrobotics/testing/compare/... + +**Note to maintainers**:: Remember to **Merge** with commit (not squash-merge +or rebase) From e8add1af807d6a799170f42e42dee421b91da54b Mon Sep 17 00:00:00 2001 From: Jenn Nguyen Date: Thu, 4 Feb 2021 18:54:42 -0800 Subject: [PATCH 62/69] fixed repo link (#149) Signed-off-by: Jenn Nguyen --- .github/PULL_REQUEST_TEMPLATE/port.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/PULL_REQUEST_TEMPLATE/port.md b/.github/PULL_REQUEST_TEMPLATE/port.md index 6066e894..a40abe6a 100644 --- a/.github/PULL_REQUEST_TEMPLATE/port.md +++ b/.github/PULL_REQUEST_TEMPLATE/port.md @@ -1,6 +1,6 @@ Port to -Branch comparison: https://github.com/ignitionrobotics/testing/compare/... +Branch comparison: https://github.com/ignitionrobotics/ign-cmake/compare/... **Note to maintainers**:: Remember to **Merge** with commit (not squash-merge or rebase) From a00a8c9180f1419a0680eb7907f0c9860bc38abc Mon Sep 17 00:00:00 2001 From: Ashton Larkin Date: Wed, 10 Feb 2021 18:25:31 -0500 Subject: [PATCH 63/69] Update codeowners (#151) Signed-off-by: Ashton Larkin --- .github/CODEOWNERS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index ee6e8a64..d68d34e6 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -2,3 +2,5 @@ # https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners * @mxgrey +* @adlarkin +* @j-rivero From b58ce507c0d3667b03912a5c6e4edab8981639e9 Mon Sep 17 00:00:00 2001 From: Jenn Nguyen Date: Fri, 12 Feb 2021 15:53:23 -0800 Subject: [PATCH 64/69] Added port & release to PR templates (#152) * added port & release to PR templates Signed-off-by: Jenn Nguyen * updated branch comparision links Signed-off-by: Jenn Nguyen * updated PR template Signed-off-by: Jenn Nguyen * updated PR template Signed-off-by: Jenn Nguyen --- .github/ISSUE_TEMPLATE/feature_request.md | 2 +- .github/PULL_REQUEST_TEMPLATE.md | 64 ++++++++++++++++++----- .github/PULL_REQUEST_TEMPLATE/port.md | 6 --- 3 files changed, 51 insertions(+), 21 deletions(-) delete mode 100644 .github/PULL_REQUEST_TEMPLATE/port.md diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index f49727a0..87233a47 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -5,7 +5,7 @@ labels: enhancement --- ## Desired behavior diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 6c88bd54..139c894f 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,9 +1,14 @@ - + -Fixes issue # +# Bug fix + +Fixes # ## Summary - [ ] Added tests - [ ] Updated documentation (as needed) - [ ] Updated migration guide (as needed) -- [ ] `codecheck` passed (See - [contributing](https://ignitionrobotics.org/docs/all/contributing#contributing-code)) -- [ ] All tests passed (See - [test coverage](https://ignitionrobotics.org/docs/all/contributing#test-coverage)) -- [ ] While waiting for a review on your PR, please help review -[another open pull request](https://github.com/pulls?q=is%3Aopen+is%3Apr+user%3Aignitionrobotics+archived%3Afalse+) -to support the maintainers +- [ ] `codecheck` passed (See [contributing](https://ignitionrobotics.org/docs/all/contributing#contributing-code)) +- [ ] All tests passed (See [test coverage](https://ignitionrobotics.org/docs/all/contributing#test-coverage)) +- [ ] While waiting for a review on your PR, please help review [another open pull request](https://github.com/pulls?q=is%3Aopen+is%3Apr+user%3Aignitionrobotics+repo%3Aosrf%2Fsdformat+archived%3Afalse+) to support the maintainers **Note to maintainers**: Remember to use **Squash-Merge** @@ -40,13 +41,48 @@ context (e.g., screenshots, gifs) if appropriate.--> ## Checklist - [ ] Signed all commits for DCO - [ ] Added tests -- [ ] Added example world and/or tutorial +- [ ] Added example and/or tutorial - [ ] Updated documentation (as needed) - [ ] Updated migration guide (as needed) - [ ] `codecheck` passed (See [contributing](https://ignitionrobotics.org/docs/all/contributing#contributing-code)) - [ ] All tests passed (See [test coverage](https://ignitionrobotics.org/docs/all/contributing#test-coverage)) -- [ ] While waiting for a review on your PR, please help review -[another open pull request](https://github.com/pulls?q=is%3Aopen+is%3Apr+user%3Aignitionrobotics+archived%3Afalse+) +- [ ] While waiting for a review on your PR, please help review [another open pull request](https://github.com/pulls?q=is%3Aopen+is%3Apr+user%3Aignitionrobotics+repo%3Aosrf%2Fsdformat+archived%3Afalse+) to support the maintainers **Note to maintainers**: Remember to use **Squash-Merge** + +--- + +# Forward port + +Port to + +Branch comparison: https://github.com/ignitionrobotics/ign-cmake/compare/... + +**Note to maintainers**: Remember to **Merge** with commit (not squash-merge or rebase) + +--- + + + +# Release + +Preparation for release. + +Comparison to : https://github.com/ignitionrobotics/ign-cmake/compare/... + + +Needed by + +## Checklist +- [ ] Asked team if this is a good time for a release +- [ ] There are no changes to be ported from the previous major version +- [ ] No PRs targeted at this major version are close to getting in +- [ ] Bumped minor for new features, patch for bug fixes +- [ ] Updated changelog +- [ ] Updated migration guide (as needed) +- [ ] Link to PR updating dependency versions in appropriate repository in [ignition-release](https://github.com/ignition-release) (as needed): + + + +**Note to maintainers**: Remember to use **Squash-Merge** diff --git a/.github/PULL_REQUEST_TEMPLATE/port.md b/.github/PULL_REQUEST_TEMPLATE/port.md deleted file mode 100644 index a40abe6a..00000000 --- a/.github/PULL_REQUEST_TEMPLATE/port.md +++ /dev/null @@ -1,6 +0,0 @@ -Port to - -Branch comparison: https://github.com/ignitionrobotics/ign-cmake/compare/... - -**Note to maintainers**:: Remember to **Merge** with commit (not squash-merge -or rebase) From f0382f5bea1f831b2cdc6556bc43aac444cb9e38 Mon Sep 17 00:00:00 2001 From: Ashton Larkin Date: Tue, 16 Feb 2021 09:39:06 -0500 Subject: [PATCH 65/69] Fix codeownders (#155) Signed-off-by: Ashton Larkin --- .github/CODEOWNERS | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index d68d34e6..30f57127 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,6 +1,4 @@ # More info: # https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners -* @mxgrey -* @adlarkin -* @j-rivero +* @mxgrey @adlarkin @j-rivero From aac33b32561e8ea4742bb9269bf4059e9660f48f Mon Sep 17 00:00:00 2001 From: Jenn Nguyen Date: Tue, 16 Feb 2021 14:53:41 -0800 Subject: [PATCH 66/69] Remove issue & PR templates (#153) Signed-off-by: Jenn Nguyen --- .github/ISSUE_TEMPLATE/bug_report.md | 29 -------- .github/ISSUE_TEMPLATE/feature_request.md | 23 ------ .github/PULL_REQUEST_TEMPLATE.md | 88 ----------------------- 3 files changed, 140 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/bug_report.md delete mode 100644 .github/ISSUE_TEMPLATE/feature_request.md delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index 3d89f641..00000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,29 +0,0 @@ ---- -name: Bug report -about: Report a bug -labels: bug ---- - - - -## Environment -* OS Version: -* Source or binary build? - - - -## Description -* Expected behavior: -* Actual behavior: - -## Steps to reproduce - - -1. -2. -3. - -## Output - diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index 87233a47..00000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,23 +0,0 @@ ---- -name: Feature request -about: Request a new feature -labels: enhancement ---- - - - -## Desired behavior - - -## Alternatives considered - - -## Implementation suggestion - - -## Additional context - diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 139c894f..00000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,88 +0,0 @@ - - -# Bug fix - -Fixes # - -## Summary - - -## Checklist -- [ ] Signed all commits for DCO -- [ ] Added tests -- [ ] Updated documentation (as needed) -- [ ] Updated migration guide (as needed) -- [ ] `codecheck` passed (See [contributing](https://ignitionrobotics.org/docs/all/contributing#contributing-code)) -- [ ] All tests passed (See [test coverage](https://ignitionrobotics.org/docs/all/contributing#test-coverage)) -- [ ] While waiting for a review on your PR, please help review [another open pull request](https://github.com/pulls?q=is%3Aopen+is%3Apr+user%3Aignitionrobotics+repo%3Aosrf%2Fsdformat+archived%3Afalse+) to support the maintainers - -**Note to maintainers**: Remember to use **Squash-Merge** - ---- - -# New feature - -Closes # - -## Summary - - -## Test it - - -## Checklist -- [ ] Signed all commits for DCO -- [ ] Added tests -- [ ] Added example and/or tutorial -- [ ] Updated documentation (as needed) -- [ ] Updated migration guide (as needed) -- [ ] `codecheck` passed (See [contributing](https://ignitionrobotics.org/docs/all/contributing#contributing-code)) -- [ ] All tests passed (See [test coverage](https://ignitionrobotics.org/docs/all/contributing#test-coverage)) -- [ ] While waiting for a review on your PR, please help review [another open pull request](https://github.com/pulls?q=is%3Aopen+is%3Apr+user%3Aignitionrobotics+repo%3Aosrf%2Fsdformat+archived%3Afalse+) -to support the maintainers - -**Note to maintainers**: Remember to use **Squash-Merge** - ---- - -# Forward port - -Port to - -Branch comparison: https://github.com/ignitionrobotics/ign-cmake/compare/... - -**Note to maintainers**: Remember to **Merge** with commit (not squash-merge or rebase) - ---- - - - -# Release - -Preparation for release. - -Comparison to : https://github.com/ignitionrobotics/ign-cmake/compare/... - - -Needed by - -## Checklist -- [ ] Asked team if this is a good time for a release -- [ ] There are no changes to be ported from the previous major version -- [ ] No PRs targeted at this major version are close to getting in -- [ ] Bumped minor for new features, patch for bug fixes -- [ ] Updated changelog -- [ ] Updated migration guide (as needed) -- [ ] Link to PR updating dependency versions in appropriate repository in [ignition-release](https://github.com/ignition-release) (as needed): - - - -**Note to maintainers**: Remember to use **Squash-Merge** From f907b0b09186d8f3884e41ec16d3d624705c8cd3 Mon Sep 17 00:00:00 2001 From: Martin Pecka Date: Thu, 25 Feb 2021 21:31:42 +0100 Subject: [PATCH 67/69] Support imported targets in FindIgnOGRE.cmake (#150) Signed-off-by: Martin Pecka --- cmake/FindIgnOGRE.cmake | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmake/FindIgnOGRE.cmake b/cmake/FindIgnOGRE.cmake index 3c7b9e18..b6da7c55 100644 --- a/cmake/FindIgnOGRE.cmake +++ b/cmake/FindIgnOGRE.cmake @@ -191,7 +191,10 @@ else() # Some Ogre libraries are not using the .lib extension set(postfix "") if(NOT ogre_lib MATCHES ".lib$") - set(postfix ".lib") + # Do not consider imported targets as libraries + if(NOT ogre_lib MATCHES "::") + set(postfix ".lib") + endif() endif() set(lib_fullpath "${prefix}${ogre_lib}${postfix}") endif() From 4d2a19a9abea60d5b75616c9b3f6481beef7a438 Mon Sep 17 00:00:00 2001 From: Louise Poubel Date: Thu, 25 Feb 2021 12:37:54 -0800 Subject: [PATCH 68/69] README tweaks (#158) Signed-off-by: Louise Poubel --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index f0e476c3..bd27cdc3 100644 --- a/README.md +++ b/README.md @@ -20,9 +20,9 @@ Windows | [![Build Status](https://build.osrfoundation.org/buildStatus/ico [Installation](#install) -* [Binary Installation](#binary-install) +* [Binary Install](#binary-install) -* [Source Installation](#source-install) +* [Source Install](#source-install) * [Prerequisites](#prerequisites) @@ -34,7 +34,7 @@ Windows | [![Build Status](https://build.osrfoundation.org/buildStatus/ico [Code of Conduct](#code-of-conduct) -[Contributing](#code-of-contributing) +[Contributing](#contributing) [Versioning](#versioning) @@ -48,11 +48,11 @@ These modules are tailored to the ignition projects, so their use for non-igniti # Install -We recommend following the [Binary Installation](#binary-install) instructions to get up and running as quickly and painlessly as possible. +We recommend following the [Binary Install](#binary-install) instructions to get up and running as quickly and painlessly as possible. -The [Source Installation](#source-install) instructions should be used if you need the very latest software improvements, you need to modify the code, or you plan to make a contribution. +The [Source Install](#source-install) instructions should be used if you need the very latest software improvements, you need to modify the code, or you plan to make a contribution. -## Binary Installation +## Binary Install On Ubuntu systems, `apt-get` can be used to install `ignition-cmake`: @@ -62,7 +62,7 @@ $ sudo apt install libignition-cmake<#>-dev Be sure to replace `<#>` with a number value, such as `1` or `2`, depending on which version you need. -## Source Installation +## Source Install ### Prerequisites From 96faa49e4905bb3986341724cd605fb96f2f19be Mon Sep 17 00:00:00 2001 From: Mabel Zhang Date: Thu, 25 Feb 2021 20:52:50 -0500 Subject: [PATCH 69/69] fix cmake message types (#159) Signed-off-by: Mabel Zhang --- cmake/IgnConfigureBuild.cmake | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cmake/IgnConfigureBuild.cmake b/cmake/IgnConfigureBuild.cmake index 3d57c131..7aafb771 100644 --- a/cmake/IgnConfigureBuild.cmake +++ b/cmake/IgnConfigureBuild.cmake @@ -46,19 +46,19 @@ macro(ign_configure_build) #============================================================================ # Print warnings and errors if(build_warnings) - message("-- BUILD WARNINGS") + message(WARNING "-- BUILD WARNINGS") foreach (msg ${build_warnings}) - message("-- ${msg}") + message(WARNING "-- ${msg}") endforeach () - message("-- END BUILD WARNINGS\n") + message(WARNING "-- END BUILD WARNINGS\n") endif (build_warnings) if(build_errors) - message("-- BUILD ERRORS: These must be resolved before compiling.") + message(SEND_ERROR "-- BUILD ERRORS: These must be resolved before compiling.") foreach(msg ${build_errors}) - message("-- ${msg}") + message(SEND_ERROR "-- ${msg}") endforeach() - message("-- END BUILD ERRORS\n") + message(SEND_ERROR "-- END BUILD ERRORS\n") set(error_str "Errors encountered in build. Please see BUILD ERRORS above.")