diff --git a/CMakeLists.txt b/CMakeLists.txt index 8df75d17d..a1f7d8966 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,360 +4,63 @@ if(COMMAND CMAKE_POLICY) CMAKE_POLICY(SET CMP0003 NEW) CMAKE_POLICY(SET CMP0004 NEW) endif(COMMAND CMAKE_POLICY) -enable_testing() -# with -fPIC -if(UNIX AND NOT WIN32) - set (CMAKE_INSTALL_PREFIX "/usr" CACHE STRING "Install Prefix") - find_program(CMAKE_UNAME uname /bin /usr/bin /usr/local/bin ) - if(CMAKE_UNAME) - exec_program(uname ARGS -m OUTPUT_VARIABLE CMAKE_SYSTEM_PROCESSOR) - set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR} CACHE INTERNAL - "processor type (i386 and x86_64)") - if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") - ADD_DEFINITIONS(-fPIC) - endif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") - endif(CMAKE_UNAME) -endif() - -project (sdformat13) +project (sdformat13 VERSION 13.0.0) # The protocol version has nothing to do with the package version set below. # It represents the current version of sdformat implement by the software set (SDF_PROTOCOL_VERSION 1.9) -set (SDF_MAJOR_VERSION 13) -set (SDF_MINOR_VERSION 0) -set (SDF_PATCH_VERSION 0) - -set (SDF_VERSION ${SDF_MAJOR_VERSION}.${SDF_MINOR_VERSION}) -set (SDF_VERSION_FULL ${SDF_MAJOR_VERSION}.${SDF_MINOR_VERSION}.${SDF_PATCH_VERSION}~pre1) - -string (TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER) -string(REGEX REPLACE "[0-9]+" "" PROJECT_NAME_NO_VERSION ${PROJECT_NAME}) -string(TOLOWER ${PROJECT_NAME_NO_VERSION} PROJECT_NAME_NO_VERSION_LOWER) -set(PROJECT_EXPORT_NAME ${PROJECT_NAME_LOWER}) -set(PROJECT_LIBRARY_TARGET_NAME ${PROJECT_NAME_LOWER}) - set (project_cmake_dir ${PROJECT_SOURCE_DIR}/cmake CACHE PATH "Location of CMake scripts") -message (STATUS "${PROJECT_NAME} version ${SDF_VERSION_FULL}") -set (CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON) - -#============================================================================ -# We turn off extensions because (1) we do not ever want to use non-standard -# compiler extensions, and (2) this variable is on by default, causing cmake -# to choose the flag -std=gnu++14 instead of -std=c++14 when the C++14 -# features are requested. Explicitly turning this flag off will force cmake to -# choose -std=c++14. -# See https://github.com/ignitionrobotics/ign-cmake/issues/13 for more info. -set(CMAKE_CXX_EXTENSIONS off) - -# Include GNUInstallDirs to get canonical paths -include(GNUInstallDirs) - -# Default test type for test all over source -set(TEST_TYPE "UNIT") - -# developer's option to cache PKG_CONFIG_PATH and -# LD_LIBRARY_PATH for local installs -if(PKG_CONFIG_PATH) - set (ENV{PKG_CONFIG_PATH} ${PKG_CONFIG_PATH}:$ENV{PKG_CONFIG_PATH}) -endif() -if(LD_LIBRARY_PATH) - set (ENV{LD_LIBRARY_PATH} ${LD_LIBRARY_PATH}:$ENV{LD_LIBRARY_PATH}) -endif() - -set (INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}/sdformat-${SDF_VERSION}/sdf") -set (LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR} CACHE STRING "Installation directory for libraries (relative to CMAKE_INSTALL_PREFIX)") -set (BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR} CACHE STRING "Installation directory for binaries (relative to CMAKE_INSTALL_PREFIX)") -set (USE_FULL_RPATH OFF CACHE BOOL "Set to true to enable full rpath") - -set(PKG_NAME SDFormat) -set(sdf_target sdformat${SDF_MAJOR_VERSION}) -set(sdf_config_install_dir "${LIB_INSTALL_DIR}/cmake/${PROJECT_NAME_LOWER}/") -set(sdf_import_target_name ${PROJECT_EXPORT_NAME}::${sdf_target}) -set(sdf_target_output_filename "${sdf_target}-targets.cmake") - +message (STATUS "${PROJECT_NAME} version ${PROJECT_VERSION_FULL}") OPTION(SDFORMAT_DISABLE_CONSOLE_LOGFILE "Disable the sdformat console logfile" OFF) -if (USE_FULL_RPATH) - # use, i.e. don't skip the full RPATH for the build tree - set(CMAKE_SKIP_BUILD_RPATH FALSE) - - # when building, don't use the install RPATH already - # (but later on when installing) - set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) - - set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}") - - # add the automatically determined parts of the RPATH - # which point to directories outside the build tree to the install RPATH - set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) - - # the RPATH to be used when installing, but only if its not a system directory - list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}" isSystemDir) - if("${isSystemDir}" STREQUAL "-1") - set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}") - endif("${isSystemDir}" STREQUAL "-1") -endif() - set (BUILD_SDF ON CACHE INTERNAL "Build SDF" FORCE) -set (build_errors "" CACHE INTERNAL "build errors" FORCE) -set (build_warnings "" CACHE INTERNAL "build warnings" FORCE) set (sdf_cmake_dir ${PROJECT_SOURCE_DIR}/cmake CACHE PATH "Location of CMake scripts") -message (STATUS "\n\n====== Finding 3rd Party Packages ======") -include (${sdf_cmake_dir}/SDFUtils.cmake) -include (${sdf_cmake_dir}/SearchForStuff.cmake) -message (STATUS "----------------------------------------\n") - -##################################### -# Set the default build type -if (NOT CMAKE_BUILD_TYPE) - set (CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING - "Choose the type of build, options are: Debug Release RelWithDebInfo Profile Check" FORCE) -endif (NOT CMAKE_BUILD_TYPE) -string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UPPERCASE) - -set (BUILD_TYPE_PROFILE FALSE) -set (BUILD_TYPE_RELEASE FALSE) -set (BUILD_TYPE_RELWITHDEBINFO FALSE) -set (BUILD_TYPE_DEBUG FALSE) - -if ("${CMAKE_BUILD_TYPE_UPPERCASE}" STREQUAL "PROFILE") - set (BUILD_TYPE_PROFILE TRUE) -elseif ("${CMAKE_BUILD_TYPE_UPPERCASE}" STREQUAL "RELEASE") - set (BUILD_TYPE_RELEASE TRUE) -elseif ("${CMAKE_BUILD_TYPE_UPPERCASE}" STREQUAL "RELWITHDEBINFO") - set (BUILD_TYPE_RELWITHDEBINFO TRUE) -elseif ("${CMAKE_BUILD_TYPE_UPPERCASE}" STREQUAL "DEBUG") - set (BUILD_TYPE_DEBUG TRUE) -elseif ("${CMAKE_BUILD_TYPE_UPPERCASE}" STREQUAL "COVERAGE") - include (${project_cmake_dir}/CodeCoverage.cmake) - set (BUILD_TYPE_DEBUG TRUE) - SETUP_TARGET_FOR_COVERAGE(coverage ctest coverage) -else() - # NONE is a valid CMAKE_BUILD_TYPE - if (NOT "${CMAKE_BUILD_TYPE_UPPERCASE}" STREQUAL "NONE") - build_error("CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} unknown. Valid options are: Debug Release RelWithDebInfo Profile Coverage None") - endif() -endif() - -#============================================================================ -# Ask whether we should make a shared or static library. -option(BUILD_SHARED_LIBS "Set this to true to generate shared libraries (recommended), or false for static libraries" ON) - -##################################### -# Handle CFlags -unset (CMAKE_C_FLAGS_ALL CACHE) - -# USE_HOST_CFLAGS (default TRUE) -# Will check building host machine for proper cflags -if(NOT DEFINED USE_HOST_CFLAGS OR USE_HOST_CFLAGS) - message(STATUS "Enable host CFlags") - include (${project_cmake_dir}/HostCFlags.cmake) -endif() - -# USE_UPSTREAM_CFLAGS (default TRUE) -# Will use predefined ignition developers cflags -if(NOT DEFINED USE_UPSTREAM_CFLAGS OR USE_UPSTREAM_CFLAGS) - message(STATUS "Enable upstream CFlags") - include(${project_cmake_dir}/DefaultCFlags.cmake) -endif() - -# Check if warning options are avaliable for the compiler and return WARNING_CXX_FLAGS variable -if (MSVC) - set(WARN_LEVEL "/W4") - - # Unable to be filtered flags (failing due to limitations in filter_valid_compiler_warnings) - # Handling exceptions rightly and ignore unknown pragmas - set(UNFILTERED_FLAGS "/EHsc /wd4068") -else() - # Equivalent to Wall (according to man gcc) but removed the unknown pragmas since we use - # MSVC only pragmas all over the code - list(APPEND WARN_LEVEL -Waddress -Warray-bounds -Wcomment -Wformat -Wnonnull) - list(APPEND WARN_LEVEL -Wparentheses -Wreorder -Wreturn-type) - list(APPEND WARN_LEVEL -Wsequence-point -Wsign-compare -Wstrict-aliasing) - list(APPEND WARN_LEVEL -Wstrict-overflow=1 -Wswitch -Wtrigraphs -Wuninitialized) - list(APPEND WARN_LEVEL -Wunused-function -Wunused-label -Wunused-value) - list(APPEND WARN_LEVEL -Wunused-variable -Wvolatile-register-var) - - # Unable to be filtered flags (failing due to limitations in filter_valid_compiler_warnings) - set(UNFILTERED_FLAGS "-Wc++17-compat") -endif() - -filter_valid_compiler_warnings(${WARN_LEVEL} -Wextra -Wno-long-long - -Wno-unused-value -Wno-unused-value -Wno-unused-value -Wno-unused-value - -Wfloat-equal -Wshadow -Winit-self -Wswitch-default - -Wmissing-include-dirs -pedantic -Wno-pragmas) -set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}${WARNING_CXX_FLAGS} ${UNFILTERED_FLAGS}") +################################################# +# Find ign-cmake +find_package(ignition-cmake2 2.9 REQUIRED) +set(IGN_CMAKE_VER ${ignition-cmake2_VERSION_MAJOR}) ################################################# # OS Specific initialization -if (UNIX) - sdf_setup_unix() -endif () - if (WIN32) sdf_setup_windows() endif () -if (APPLE) - sdf_setup_apple() -endif () - -################################################# -# Print warnings and errors -if ( build_warnings ) - message(WARNING "-- BUILD WARNINGS") - foreach (msg ${build_warnings}) - message(WARNING "-- ${msg}") - endforeach () - message(WARNING "-- END BUILD WARNINGS\n") -endif (build_warnings) - -########### Add uninstall target ############### -configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake" - IMMEDIATE @ONLY) -add_custom_target(uninstall - "${CMAKE_COMMAND}" -P - "${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake") - -if (build_errors) - message(SEND_ERROR "-- BUILD ERRORS: These must be resolved before compiling.") - foreach (msg ${build_errors}) - message(SEND_ERROR "-- ${msg}") - endforeach () - message(SEND_ERROR "-- END BUILD ERRORS\n") - message (FATAL_ERROR "Errors encountered in build. Please see the BUILD ERRORS above.") - -else (build_errors) +if (BUILD_SDF) + ign_configure_project(REPLACE_IGNITION_INCLUDE_PATH sdf NO_IGNITION_PREFIX) - ######################################## - # Write the config.h file - configure_file (${sdf_cmake_dir}/sdf_config.h.in - ${PROJECT_BINARY_DIR}/sdf/sdf_config.h) - sdf_install_includes("" ${PROJECT_BINARY_DIR}/sdf/sdf_config.h) + message (STATUS "\n\n====== Finding 3rd Party Packages ======") + include (${sdf_cmake_dir}/SDFUtils.cmake) + include (${sdf_cmake_dir}/SearchForStuff.cmake) + message (STATUS "----------------------------------------\n") - message (STATUS "C Flags:${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}}") - message (STATUS "Build Type: ${CMAKE_BUILD_TYPE}") - message (STATUS "Install path: ${CMAKE_INSTALL_PREFIX}") + ign_configure_build(QUIT_IF_BUILD_ERRORS) + ign_create_packages() - if (BUILD_SDF) - include_directories(include - ${PROJECT_BINARY_DIR} - ${PROJECT_BINARY_DIR}/include - ) + add_subdirectory(sdf) + add_subdirectory(conf) + add_subdirectory(doc) +endif(BUILD_SDF) - link_directories(${PROJECT_BINARY_DIR}/src) +######################################## +# Setup Codecheck - if (NOT DEFINED BUILD_TESTING OR BUILD_TESTING) - set(BUILD_SDF_TEST TRUE) - else() - set(BUILD_SDF_TEST FALSE) - endif() - - if (BUILD_SDF_TEST) - add_subdirectory(test) - endif() - add_subdirectory(src) - add_subdirectory(include/sdf) - add_subdirectory(sdf) - add_subdirectory(conf) - add_subdirectory(doc) - endif(BUILD_SDF) - - ######################################## - # Setup Codecheck - include (IgnCodeCheck) - set(CPPCHECK_DIRS - ${PROJECT_SOURCE_DIR}/src - ${PROJECT_SOURCE_DIR}/include - ${PROJECT_SOURCE_DIR}/test/integration - ${PROJECT_SOURCE_DIR}/test/performance) - - set(CPPCHECK_INCLUDE_DIRS - ${PROJECT_BINARY_DIR} - ${PROJECT_SOURCE_DIR}/include - ${PROJECT_SOURCE_DIR}/test/integration - ${PROJECT_SOURCE_DIR}/test/performance) - - # Ignore vendored directories. - file(WRITE ${PROJECT_BINARY_DIR}/cppcheck.suppress - "*:${PROJECT_SOURCE_DIR}/src/urdf/*\n" - ) - ign_setup_target_for_codecheck() - - ######################################## - # Make the package config file - set(PC_CONFIG_INSTALL_DIR ${LIB_INSTALL_DIR}/pkgconfig) - file(RELATIVE_PATH - PC_CONFIG_RELATIVE_PATH_TO_PREFIX - "${CMAKE_INSTALL_PREFIX}/${PC_CONFIG_INSTALL_DIR}" - "${CMAKE_INSTALL_PREFIX}" +# Ignore vendored directories. +file(WRITE ${PROJECT_BINARY_DIR}/cppcheck.suppress + "*:${PROJECT_SOURCE_DIR}/src/urdf/*\n" ) - configure_file(${CMAKE_SOURCE_DIR}/cmake/sdformat_pc.in - ${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME_LOWER}.pc @ONLY) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME_LOWER}.pc DESTINATION - ${PC_CONFIG_INSTALL_DIR} COMPONENT pkgconfig) - - ######################################## - # Configure documentation uploader - configure_file("${CMAKE_SOURCE_DIR}/cmake/upload_doc.sh.in" - ${CMAKE_BINARY_DIR}/upload_doc.sh @ONLY) - - ######################################## - # Make the cmake config files - set(sdf_config_input "${CMAKE_CURRENT_SOURCE_DIR}/cmake/sdf_config.cmake.in") - set(sdf_config_output "cmake/${sdf_target}-config.cmake") - set(sdf_version_output "cmake/${sdf_target}-config-version.cmake") - set(sdf_config_install_dir "${LIB_INSTALL_DIR}/cmake/${PROJECT_NAME_LOWER}/") - - include(CMakePackageConfigHelpers) - #-------------------------------------- - # Configure and install the config file - configure_package_config_file( - ${sdf_config_input} - ${sdf_config_output} - INSTALL_DESTINATION ${sdf_config_install_dir} - NO_CHECK_REQUIRED_COMPONENTS_MACRO) - - #-------------------------------------- - # Configure and install the version file - write_basic_package_version_file( - ${CMAKE_CURRENT_BINARY_DIR}/${sdf_version_output} - VERSION "${SDF_VERSION_FULL}" - COMPATIBILITY SameMajorVersion) - - install(FILES - ${CMAKE_CURRENT_BINARY_DIR}/${sdf_config_output} - ${CMAKE_CURRENT_BINARY_DIR}/${sdf_version_output} - DESTINATION ${sdf_config_install_dir} - COMPONENT cmake) - - ######################################## - # Package Creation: - include (${sdf_cmake_dir}/sdf_cpack.cmake) - set (CPACK_PACKAGE_VERSION "${SDF_VERSION_FULL}") - set (CPACK_PACKAGE_VERSION_MAJOR "${SDF_MAJOR_VERSION}") - set (CPACK_PACKAGE_VERSION_MINOR "${SDF_MINOR_VERSION}") - set (CPACK_PACKAGE_VERSION_PATCH "${SDF_PATCH_VERSION}") - - if (CPACK_GENERATOR) - message(STATUS "Found CPack generators: ${CPACK_GENERATOR}") - configure_file("${sdf_cmake_dir}/cpack_options.cmake.in" - ${SDF_CPACK_CFG_FILE} @ONLY) - set(CPACK_PROJECT_CONFIG_FILE ${SDF_CPACK_CFG_FILE}) - include (CPack) - endif() +######################################## +# Configure documentation uploader +configure_file("${CMAKE_SOURCE_DIR}/cmake/upload_doc.sh.in" + ${CMAKE_BINARY_DIR}/upload_doc.sh @ONLY) - message(STATUS "Configuration successful. Type make to compile sdf") -endif(build_errors) +message(STATUS "Configuration successful. Type make to compile sdf") diff --git a/cmake/CodeCoverage.cmake b/cmake/CodeCoverage.cmake deleted file mode 100644 index 7eb4f7c56..000000000 --- a/cmake/CodeCoverage.cmake +++ /dev/null @@ -1,135 +0,0 @@ -# -# 2012-01-31, Lars Bilke -# - Enable Code Coverage -# -# 2013-09-17, Joakim Söderberg -# - Added support for Clang. -# - Some additional usage instructions. -# -# USAGE: -# 1. Copy this file into your cmake modules path. -# -# 2. Add the following line to your CMakeLists.txt: -# INCLUDE(CodeCoverage) -# -# 3. Set compiler flags to turn off optimization and enable coverage: -# SET(CMAKE_CXX_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage") -# SET(CMAKE_C_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage") -# -# 3. Use the function SETUP_TARGET_FOR_COVERAGE to create a custom make target -# which runs your test executable and produces a lcov code coverage report: -# Example: -# SETUP_TARGET_FOR_COVERAGE( -# my_coverage_target # Name for custom target. -# test_driver # Name of the test driver executable that runs the tests. -# # NOTE! This should always have a ZERO as exit code -# # otherwise the coverage generation will not complete. -# coverage # Name of output directory. -# ) -# -# 4. Build a Debug build: -# cmake -DCMAKE_BUILD_TYPE=Debug .. -# make -# make my_coverage_target -# -# - -# Check prereqs - -FIND_PROGRAM( GCOV_PATH NAMES gcov-8 gcov ) -FIND_PROGRAM( LCOV_PATH lcov ) -FIND_PROGRAM( GREP_PATH grep ) -FIND_PROGRAM( GENHTML_PATH genhtml ) -FIND_PROGRAM( GCOVR_PATH gcovr PATHS ${CMAKE_SOURCE_DIR}/tests) - -IF(NOT GCOV_PATH) - MESSAGE(FATAL_ERROR "gcov not found! Aborting...") -ENDIF() # NOT GCOV_PATH - -IF(NOT CMAKE_COMPILER_IS_GNUCXX) - # Clang version 3.0.0 and greater now supports gcov as well. - MESSAGE(WARNING "Compiler is not GNU gcc! Clang Version 3.0.0 and greater supports gcov as well, but older versions don't.") - - IF(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - MESSAGE(FATAL_ERROR "Compiler is not GNU gcc! Aborting...") - ENDIF() -ENDIF() # NOT CMAKE_COMPILER_IS_GNUCXX - -SET(CMAKE_CXX_FLAGS_COVERAGE - "-g -O0 --coverage -fprofile-arcs -ftest-coverage" - CACHE STRING "Flags used by the C++ compiler during coverage builds." - FORCE ) -SET(CMAKE_C_FLAGS_COVERAGE - "-g -O0 --coverage -fprofile-arcs -ftest-coverage" - CACHE STRING "Flags used by the C compiler during coverage builds." - FORCE ) -SET(CMAKE_EXE_LINKER_FLAGS_COVERAGE - "" - CACHE STRING "Flags used for linking binaries during coverage builds." - FORCE ) -SET(CMAKE_SHARED_LINKER_FLAGS_COVERAGE - "" - CACHE STRING "Flags used by the shared libraries linker during coverage builds." - FORCE ) -MARK_AS_ADVANCED( - CMAKE_CXX_FLAGS_COVERAGE - CMAKE_C_FLAGS_COVERAGE - CMAKE_EXE_LINKER_FLAGS_COVERAGE - CMAKE_SHARED_LINKER_FLAGS_COVERAGE ) - -IF ( NOT (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "Coverage")) - MESSAGE( WARNING "Code coverage results with an optimized (non-Debug) build may be misleading" ) -ENDIF() # NOT CMAKE_BUILD_TYPE STREQUAL "Debug" - - -# Param _targetname The name of new the custom make target -# Param _testrunner The name of the target which runs the tests. -# MUST return ZERO always, even on errors. -# If not, no coverage report will be created! -# Param _outputname lcov output is generated as _outputname.info -# HTML report is generated in _outputname/index.html -# Optional fourth parameter is passed as arguments to _testrunner -# Pass them in list form, e.g.: "-j;2" for -j 2 -FUNCTION(SETUP_TARGET_FOR_COVERAGE _targetname _testrunner _outputname) - - IF(NOT LCOV_PATH) - MESSAGE(FATAL_ERROR "lcov not found! Aborting...") - ENDIF() # NOT LCOV_PATH - - IF(NOT GENHTML_PATH) - MESSAGE(FATAL_ERROR "genhtml not found! Aborting...") - ENDIF() # NOT GENHTML_PATH - - IF(NOT GREP_PATH) - MESSAGE(FATAL_ERROR "grep not found! Run code coverage on linux or mac.") - ENDIF() - - # Setup target - ADD_CUSTOM_TARGET(${_targetname} - - COMMAND ${CMAKE_COMMAND} -E remove ${_outputname}.info.cleaned - ${_outputname}.info - # Capturing lcov counters and generating report - COMMAND ${LCOV_PATH} -q --no-checksum --directory ${PROJECT_BINARY_DIR} - --gcov-tool ${GCOV_PATH} --capture --output-file ${_outputname}.info 2>/dev/null - COMMAND ${LCOV_PATH} -q --remove ${_outputname}.info - --gcov-tool ${GCOV_PATH} '*/test/*' '/usr/*' '*_TEST*' --output-file ${_outputname}.info.cleaned - COMMAND ${GENHTML_PATH} -q --legend -o ${_outputname} - ${_outputname}.info.cleaned - COMMAND ${LCOV_PATH} --summary ${_outputname}.info.cleaned 2>&1 | grep "lines" | cut -d ' ' -f 4 | cut -d '%' -f 1 > coverage/lines.txt - COMMAND ${LCOV_PATH} --summary ${_outputname}.info.cleaned 2>&1 | grep "functions" | cut -d ' ' -f 4 | cut -d '%' -f 1 > coverage/functions.txt - COMMAND ${CMAKE_COMMAND} -E rename ${_outputname}.info.cleaned - ${_outputname}.info - - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - COMMENT "Resetting code coverage counters to zero.\n" - "Processing code coverage counters and generating report." - ) - - # Show info where to find the report - ADD_CUSTOM_COMMAND(TARGET ${_targetname} POST_BUILD - COMMAND COMMAND ${LCOV_PATH} -q --zerocounters --directory ${PROJECT_BINARY_DIR}; - COMMENT "Open ./${_outputname}/index.html in your browser to view the coverage report." - ) - -ENDFUNCTION() # SETUP_TARGET_FOR_COVERAGE diff --git a/cmake/DefaultCFlags.cmake b/cmake/DefaultCFlags.cmake deleted file mode 100644 index be57d0a3d..000000000 --- a/cmake/DefaultCFlags.cmake +++ /dev/null @@ -1,79 +0,0 @@ -# Build type link flags -set (CMAKE_LINK_FLAGS_RELEASE " " CACHE INTERNAL "Link flags for release" FORCE) -set (CMAKE_LINK_FLAGS_RELWITHDEBINFO " " CACHE INTERNAL "Link flags for release with debug support" FORCE) -set (CMAKE_LINK_FLAGS_DEBUG " " CACHE INTERNAL "Link flags for debug" FORCE) -set (CMAKE_LINK_FLAGS_PROFILE " -pg" CACHE INTERNAL "Link flags for profile" FORCE) -set (CMAKE_LINK_FLAGS_COVERAGE " --coverage" CACHE INTERNAL "Link flags for static code coverage" FORCE) - -set (CMAKE_C_FLAGS_RELEASE "") -if (NOT "${CMAKE_CXX_COMPILER_ID} " STREQUAL "Clang " AND NOT MSVC) - # -s doesn't work with clang or Visual Studio, see alternative in link below: - # http://stackoverflow.com/questions/6085491/gcc-vs-clang-symbol-strippingu - set (CMAKE_C_FLAGS_RELEASE "-s") -endif() - -if (NOT MSVC) - set (CMAKE_C_FLAGS_RELEASE " ${CMAKE_C_FLAGS_RELEASE} -O3 -DNDEBUG ${CMAKE_C_FLAGS_ALL}" CACHE INTERNAL "C Flags for release" FORCE) - set (CMAKE_CXX_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE}) - - set (CMAKE_C_FLAGS_RELWITHDEBINFO " -g -O2 ${CMAKE_C_FLAGS_ALL}" CACHE INTERNAL "C Flags for release with debug support" FORCE) - set (CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_C_FLAGS_RELWITHDEBINFO}) - - set (CMAKE_C_FLAGS_DEBUG " -ggdb3 ${CMAKE_C_FLAGS_ALL}" CACHE INTERNAL "C Flags for debug" FORCE) - set (CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG}) - - set (CMAKE_C_FLAGS_PROFILE " -fno-omit-frame-pointer -g -pg ${CMAKE_C_FLAGS_ALL}" CACHE INTERNAL "C Flags for profile" FORCE) - set (CMAKE_CXX_FLAGS_PROFILE ${CMAKE_C_FLAGS_PROFILE}) - - set (CMAKE_C_FLAGS_COVERAGE " -g -O0 -Wformat=2 --coverage -fno-inline ${CMAKE_C_FLAGS_ALL}" CACHE INTERNAL "C Flags for static code coverage" FORCE) - set (CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_C_FLAGS_COVERAGE}") - foreach(flag - -fno-default-inline - -fno-elide-constructors - -fno-implicit-inline-templates) - CHECK_CXX_COMPILER_FLAG(${flag} R${flag}) - if (R${flag}) - set (CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_COVERAGE} ${flag}") - endif() - endforeach() -endif() - -##################################### -# Set all the global build flags -set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UPPERCASE}}") -set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UPPERCASE}}") -set (CMAKE_CXX_EXTENSIONS off) -set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_LINK_FLAGS_${CMAKE_BUILD_TYPE_UPPERCASE}}") -set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_LINK_FLAGS_${CMAKE_BUILD_TYPE_UPPERCASE}}") -set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${CMAKE_LINK_FLAGS_${CMAKE_BUILD_TYPE_UPPERCASE}}") - -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -if (UNIX) - # Add visibility in UNIX - check_gcc_visibility() - if (GCC_SUPPORTS_VISIBILITY) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") - endif() -endif() - -# Compiler-specific C++17 activation. -if ("${CMAKE_CXX_COMPILER_ID} " MATCHES "GNU ") - execute_process( - COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION) - if (NOT (GCC_VERSION VERSION_GREATER_EQUAL 7.0)) - message(STATUS "Found version ${GCC_VERSION}") - message(FATAL_ERROR "${PROJECT_NAME} requires g++ 7.0 or greater.") - endif () -elseif ("${CMAKE_CXX_COMPILER_ID} " MATCHES "Clang ") - if(APPLE) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") - endif() -elseif ("${CMAKE_CXX_COMPILER_ID} " STREQUAL "MSVC ") - if (MSVC_VERSION LESS 1914) - message(FATAL_ERROR "${PROJECT_NAME} requires VS 2017 or greater.") - endif() -else () - message(FATAL_ERROR "Your C++ compiler does not support C++17.") -endif () diff --git a/cmake/FindSSE.cmake b/cmake/FindSSE.cmake deleted file mode 100644 index cdbcfcc3d..000000000 --- a/cmake/FindSSE.cmake +++ /dev/null @@ -1,115 +0,0 @@ -# Check if SSE instructions are available on the machine where -# the project is compiled. - -IF (ARCH MATCHES "i386" OR ARCH MATCHES "x86_64") - IF(CMAKE_SYSTEM_NAME MATCHES "Linux") - EXEC_PROGRAM(cat ARGS "/proc/cpuinfo" OUTPUT_VARIABLE CPUINFO) - - STRING(REGEX REPLACE "^.*(sse2).*$" "\\1" SSE_THERE ${CPUINFO}) - STRING(COMPARE EQUAL "sse2" "${SSE_THERE}" SSE2_TRUE) - IF (SSE2_TRUE) - set(SSE2_FOUND true CACHE BOOL "SSE2 available on host") - ELSE (SSE2_TRUE) - set(SSE2_FOUND false CACHE BOOL "SSE2 available on host") - ENDIF (SSE2_TRUE) - - # /proc/cpuinfo apparently omits sse3 :( - STRING(REGEX REPLACE "^.*[^s](sse3).*$" "\\1" SSE_THERE ${CPUINFO}) - STRING(COMPARE EQUAL "sse3" "${SSE_THERE}" SSE3_TRUE) - IF (NOT SSE3_TRUE) - STRING(REGEX REPLACE "^.*(T2300).*$" "\\1" SSE_THERE ${CPUINFO}) - STRING(COMPARE EQUAL "T2300" "${SSE_THERE}" SSE3_TRUE) - ENDIF (NOT SSE3_TRUE) - - STRING(REGEX REPLACE "^.*(ssse3).*$" "\\1" SSE_THERE ${CPUINFO}) - STRING(COMPARE EQUAL "ssse3" "${SSE_THERE}" SSSE3_TRUE) - IF (SSE3_TRUE OR SSSE3_TRUE) - set(SSE3_FOUND true CACHE BOOL "SSE3 available on host") - ELSE (SSE3_TRUE OR SSSE3_TRUE) - set(SSE3_FOUND false CACHE BOOL "SSE3 available on host") - ENDIF (SSE3_TRUE OR SSSE3_TRUE) - IF (SSSE3_TRUE) - set(SSSE3_FOUND true CACHE BOOL "SSSE3 available on host") - ELSE (SSSE3_TRUE) - set(SSSE3_FOUND false CACHE BOOL "SSSE3 available on host") - ENDIF (SSSE3_TRUE) - - STRING(REGEX REPLACE "^.*(sse4_1).*$" "\\1" SSE_THERE ${CPUINFO}) - STRING(COMPARE EQUAL "sse4_1" "${SSE_THERE}" SSE41_TRUE) - IF (SSE41_TRUE) - set(SSE4_1_FOUND true CACHE BOOL "SSE4.1 available on host") - ELSE (SSE41_TRUE) - set(SSE4_1_FOUND false CACHE BOOL "SSE4.1 available on host") - ENDIF (SSE41_TRUE) - - STRING(REGEX REPLACE "^.*(sse4_2).*$" "\\1" SSE_THERE ${CPUINFO}) - STRING(COMPARE EQUAL "sse4_2" "${SSE_THERE}" SSE42_TRUE) - IF (SSE42_TRUE) - set(SSE4_2_FOUND true CACHE BOOL "SSE4.2 available on host") - ELSE (SSE42_TRUE) - set(SSE4_2_FOUND false CACHE BOOL "SSE4.2 available on host") - ENDIF (SSE42_TRUE) - - ELSEIF(CMAKE_SYSTEM_NAME MATCHES "Darwin") - EXEC_PROGRAM("/usr/sbin/sysctl -n machdep.cpu.features" OUTPUT_VARIABLE - CPUINFO) - - STRING(REGEX REPLACE "^.*[^S](SSE2).*$" "\\1" SSE_THERE ${CPUINFO}) - STRING(COMPARE EQUAL "SSE2" "${SSE_THERE}" SSE2_TRUE) - IF (SSE2_TRUE) - set(SSE2_FOUND true CACHE BOOL "SSE2 available on host") - ELSE (SSE2_TRUE) - set(SSE2_FOUND false CACHE BOOL "SSE2 available on host") - ENDIF (SSE2_TRUE) - - STRING(REGEX REPLACE "^.*[^S](SSE3).*$" "\\1" SSE_THERE ${CPUINFO}) - STRING(COMPARE EQUAL "SSE3" "${SSE_THERE}" SSE3_TRUE) - IF (SSE3_TRUE) - set(SSE3_FOUND true CACHE BOOL "SSE3 available on host") - ELSE (SSE3_TRUE) - set(SSE3_FOUND false CACHE BOOL "SSE3 available on host") - ENDIF (SSE3_TRUE) - - STRING(REGEX REPLACE "^.*(SSSE3).*$" "\\1" SSE_THERE ${CPUINFO}) - STRING(COMPARE EQUAL "SSSE3" "${SSE_THERE}" SSSE3_TRUE) - IF (SSSE3_TRUE) - set(SSSE3_FOUND true CACHE BOOL "SSSE3 available on host") - ELSE (SSSE3_TRUE) - set(SSSE3_FOUND false CACHE BOOL "SSSE3 available on host") - ENDIF (SSSE3_TRUE) - - STRING(REGEX REPLACE "^.*(SSE4.1).*$" "\\1" SSE_THERE ${CPUINFO}) - STRING(COMPARE EQUAL "SSE4.1" "${SSE_THERE}" SSE41_TRUE) - IF (SSE41_TRUE) - set(SSE4_1_FOUND true CACHE BOOL "SSE4.1 available on host") - ELSE (SSE41_TRUE) - set(SSE4_1_FOUND false CACHE BOOL "SSE4.1 available on host") - ENDIF (SSE41_TRUE) - ELSEIF(CMAKE_SYSTEM_NAME MATCHES "Windows") - # TODO - set(SSE2_FOUND true CACHE BOOL "SSE2 available on host") - set(SSE3_FOUND false CACHE BOOL "SSE3 available on host") - set(SSSE3_FOUND false CACHE BOOL "SSSE3 available on host") - set(SSE4_1_FOUND false CACHE BOOL "SSE4.1 available on host") - ELSE(CMAKE_SYSTEM_NAME MATCHES "Linux") - set(SSE2_FOUND true CACHE BOOL "SSE2 available on host") - set(SSE3_FOUND false CACHE BOOL "SSE3 available on host") - set(SSSE3_FOUND false CACHE BOOL "SSSE3 available on host") - set(SSE4_1_FOUND false CACHE BOOL "SSE4.1 available on host") - ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux") -ENDIF(ARCH MATCHES "i386" OR ARCH MATCHES "x86_64") - -if(NOT SSE2_FOUND) - MESSAGE(STATUS "Could not find hardware support for SSE2 on this machine.") -endif(NOT SSE2_FOUND) -if(NOT SSE3_FOUND) - MESSAGE(STATUS "Could not find hardware support for SSE3 on this machine.") -endif(NOT SSE3_FOUND) -if(NOT SSSE3_FOUND) - MESSAGE(STATUS "Could not find hardware support for SSSE3 on this machine.") -endif(NOT SSSE3_FOUND) -if(NOT SSE4_1_FOUND) - MESSAGE(STATUS "Could not find hardware support for SSE4.1 on this machine.") -endif(NOT SSE4_1_FOUND) - -mark_as_advanced(SSE2_FOUND SSE3_FOUND SSSE3_FOUND SSE4_1_FOUND) diff --git a/cmake/HostCFlags.cmake b/cmake/HostCFlags.cmake deleted file mode 100644 index f38d8d7fd..000000000 --- a/cmake/HostCFlags.cmake +++ /dev/null @@ -1,27 +0,0 @@ -include (${project_cmake_dir}/FindSSE.cmake) - -if (SSE2_FOUND) - set (CMAKE_C_FLAGS_ALL "-msse -msse2 ${CMAKE_C_FLAGS_ALL}") - if (NOT APPLE) - set (CMAKE_C_FLAGS_ALL "-mfpmath=sse ${CMAKE_C_FLAGS_ALL}") - endif() -endif() - -if (SSE3_FOUND) - set (CMAKE_C_FLAGS_ALL "-msse3 ${CMAKE_C_FLAGS_ALL}") -endif() -if (SSSE3_FOUND) - set (CMAKE_C_FLAGS_ALL "-mssse3 ${CMAKE_C_FLAGS_ALL}") -endif() - -if (SSE4_1_FOUND OR SSE4_2_FOUND) - if (SSE4_1_FOUND) - set (CMAKE_C_FLAGS_ALL "-msse4.1 ${CMAKE_C_FLAGS_ALL}") - endif() - if (SSE4_2_FOUND) - set (CMAKE_C_FLAGS_ALL "-msse4.2 ${CMAKE_C_FLAGS_ALL}") - endif() -else() - message(STATUS "\nSSE4 disabled.\n") -endif() - diff --git a/cmake/Modules/FindTinyXML2.cmake b/cmake/Modules/FindTinyXML2.cmake deleted file mode 100644 index fd3571e9b..000000000 --- a/cmake/Modules/FindTinyXML2.cmake +++ /dev/null @@ -1,42 +0,0 @@ -# CMake Logic to find system TinyXML2, sourced from: -# ros2/tinyxml2_vendor -# https://github.com/ros2/tinyxml2_vendor/commit/fde8000d31d68ff555431d63af3c324afba9f117#diff-120198e331f1dd3e7806c31af0cfb425 - -# The CMake Logic here is licensed under Apache License 2.0 -# TinyXML2 itself is licensed under the zlib License - -# TinyXML2_FOUND -# TinyXML2_INCLUDE_DIRS -# TinyXML2_LIBRARIES - -# try to find the CMake config file for TinyXML2 first -find_package(TinyXML2 CONFIG NAMES tinyxml2 QUIET) -if(TinyXML2_FOUND) - message(STATUS "Found TinyXML2 via Config file: ${TinyXML2_DIR}") - if(NOT TINYXML2_LIBRARY) - # in this case, we're probably using TinyXML2 version 5.0.0 or greater - # in which case tinyxml2 is an exported target and we should use that - if(TARGET tinyxml2) - set(TINYXML2_LIBRARY tinyxml2) - elseif(TARGET tinyxml2::tinyxml2) - set(TINYXML2_LIBRARY tinyxml2::tinyxml2) - endif() - endif() -else() - find_path(TINYXML2_INCLUDE_DIR NAMES tinyxml2.h) - - find_library(TINYXML2_LIBRARY tinyxml2) - - include(FindPackageHandleStandardArgs) - find_package_handle_standard_args(TinyXML2 DEFAULT_MSG TINYXML2_LIBRARY TINYXML2_INCLUDE_DIR) - - mark_as_advanced(TINYXML2_INCLUDE_DIR TINYXML2_LIBRARY) -endif() - -# Set mixed case INCLUDE_DIRS and LIBRARY variables from upper case ones. -if(NOT TinyXML2_INCLUDE_DIRS) - set(TinyXML2_INCLUDE_DIRS ${TINYXML2_INCLUDE_DIR}) -endif() -if(NOT TinyXML2_LIBRARIES) - set(TinyXML2_LIBRARIES ${TINYXML2_LIBRARY}) -endif() diff --git a/cmake/SDFUtils.cmake b/cmake/SDFUtils.cmake index 21ac67827..dc979f278 100644 --- a/cmake/SDFUtils.cmake +++ b/cmake/SDFUtils.cmake @@ -1,234 +1,12 @@ -################################################################################ -#APPEND_TO_CACHED_STRING(_string _cacheDesc [items...]) -# Appends items to a cached list. -MACRO (APPEND_TO_CACHED_STRING _string _cacheDesc) - FOREACH (newItem ${ARGN}) - SET (${_string} "${${_string}} ${newItem}" CACHE INTERNAL ${_cacheDesc} FORCE) - ENDFOREACH (newItem ${ARGN}) - #STRING(STRIP ${${_string}} ${_string}) -ENDMACRO (APPEND_TO_CACHED_STRING) - -################################################################################ -# APPEND_TO_CACHED_LIST (_list _cacheDesc [items...] -# Appends items to a cached list. -MACRO (APPEND_TO_CACHED_LIST _list _cacheDesc) - SET (tempList ${${_list}}) - FOREACH (newItem ${ARGN}) - LIST (APPEND tempList ${newItem}) - ENDFOREACH (newItem ${newItem}) - SET (${_list} ${tempList} CACHE INTERNAL ${_cacheDesc} FORCE) -ENDMACRO(APPEND_TO_CACHED_LIST) - -################################################# -# Macro to turn a list into a string (why doesn't CMake have this built-in?) -MACRO (LIST_TO_STRING _string _list) - SET (${_string}) - FOREACH (_item ${_list}) - SET (${_string} "${${_string}} ${_item}") - ENDFOREACH (_item) - #STRING(STRIP ${${_string}} ${_string}) -ENDMACRO (LIST_TO_STRING) - -################################################# -# BUILD ERROR macro -macro (BUILD_ERROR) - foreach (str ${ARGN}) - SET (msg "\t${str}") - MESSAGE (STATUS ${msg}) - APPEND_TO_CACHED_LIST(build_errors "build errors" ${msg}) - endforeach () -endmacro (BUILD_ERROR) - -################################################# -# BUILD WARNING macro -macro (BUILD_WARNING) - foreach (str ${ARGN}) - SET (msg "\t${str}" ) - MESSAGE (STATUS ${msg} ) - APPEND_TO_CACHED_LIST(build_warnings "build warning" ${msg}) - endforeach (str ${ARGN}) -endmacro (BUILD_WARNING) - -################################################# -macro (sdf_add_library _name) - set(LIBS_DESTINATION ${PROJECT_BINARY_DIR}/src) - add_library(${_name} ${ARGN}) - set_target_properties(${_name} PROPERTIES DEFINE_SYMBOL "BUILDING_SDFORMAT_SHARED") - if(NOT BUILD_SHARED_LIBS) - target_compile_definitions(${_name} PUBLIC SDFORMAT_STATIC_DEFINE) - endif() - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBS_DESTINATION}) - if (MSVC) - set_target_properties( ${_name} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${LIBS_DESTINATION}) - set_target_properties( ${_name} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${LIBS_DESTINATION}) - set_target_properties( ${_name} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${LIBS_DESTINATION}) - endif () -endmacro () - -################################################# -macro (sdf_add_executable _name) - add_executable(${_name} ${ARGN}) -endmacro () - - -################################################# -macro (sdf_install_includes _subdir) - install(FILES ${ARGN} DESTINATION ${INCLUDE_INSTALL_DIR}/${_subdir} COMPONENT headers) -endmacro() - -################################################# -macro (sdf_install_library _name) - set_target_properties(${_name} PROPERTIES SOVERSION ${SDF_MAJOR_VERSION} VERSION ${SDF_VERSION_FULL}) - install ( - TARGETS ${_name} - EXPORT ${_name} - ARCHIVE DESTINATION ${LIB_INSTALL_DIR} - LIBRARY DESTINATION ${LIB_INSTALL_DIR} - RUNTIME DESTINATION ${BIN_INSTALL_DIR} - COMPONENT shlib) - -# Export and install target -export( - EXPORT ${_name} - FILE ${PROJECT_BINARY_DIR}/cmake/${sdf_target_output_filename} - NAMESPACE ${PROJECT_EXPORT_NAME}::) - -install( - EXPORT ${_name} - DESTINATION ${sdf_config_install_dir} - FILE ${sdf_target_output_filename} - NAMESPACE ${PROJECT_EXPORT_NAME}::) - -endmacro () - -################################################# -macro (sdf_install_executable _name) - set_target_properties(${_name} PROPERTIES VERSION ${SDF_VERSION_FULL}) - install (TARGETS ${_name} DESTINATION ${BIN_INSTALL_DIR}) -endmacro () - -################################################# -macro (sdf_setup_unix) -endmacro() - ################################################# macro (sdf_setup_windows) # Need for M_PI constant - add_definitions(-D_USE_MATH_DEFINES -DWINDOWS_LEAN_AND_MEAN) + add_definitions(-D_USE_MATH_DEFINES) # And force linking to MSVC dynamic runtime set(CMAKE_C_FLAGS_DEBUG "/MDd ${CMAKE_C_FLAGS_DEBUG}") set(CMAKE_C_FLAGS_RELEASE "/MD ${CMAKE_C_FLAGS_RELEASE}") endmacro() -################################################# -macro (sdf_setup_apple) - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-undefined -Wl,dynamic_lookup") -endmacro() - -################################################# -# VAR: SDF_BUILD_TESTS_EXTRA_EXE_SRCS -# Hack: extra sources to build binaries can be supplied to gz_build_tests in -# the variable SDF_BUILD_TESTS_EXTRA_EXE_SRCS. This variable will be clean up -# at the end of the function -# -include_directories(${PROJECT_SOURCE_DIR}/test/gtest/include) -macro (sdf_build_tests) - # Build all the tests - foreach(GTEST_SOURCE_file ${ARGN}) - string(REGEX REPLACE ".cc" "" BINARY_NAME ${GTEST_SOURCE_file}) - set(BINARY_NAME ${TEST_TYPE}_${BINARY_NAME}) - - add_executable(${BINARY_NAME} - ${GTEST_SOURCE_file} - ${SDF_BUILD_TESTS_EXTRA_EXE_SRCS} - ) - - add_dependencies(${BINARY_NAME} - gtest gtest_main ${sdf_target} - ) - - link_directories(${IGNITION-MATH_LIBRARY_DIRS}) - target_link_libraries(${BINARY_NAME} ${tinyxml2_LIBRARIES}) - - if (UNIX) - target_link_libraries(${BINARY_NAME} PRIVATE - libgtest.a - libgtest_main.a - ${sdf_target} - pthread - ${IGNITION-MATH_LIBRARIES} - ) - elseif(WIN32) - target_link_libraries(${BINARY_NAME} PRIVATE - gtest.lib - gtest_main.lib - ${sdf_target} - ${IGNITION-MATH_LIBRARIES} - ) - - # Copy in sdformat library - add_custom_command(TARGET ${BINARY_NAME} - COMMAND ${CMAKE_COMMAND} -E copy_if_different - $ - $ VERBATIM) - - endif() - - add_test(${BINARY_NAME} ${CMAKE_CURRENT_BINARY_DIR}/${BINARY_NAME} - --gtest_output=xml:${CMAKE_BINARY_DIR}/test_results/${BINARY_NAME}.xml) - - set (_env_vars) - set (sdf_paths) - - # Get all the sdf protocol directory names - file(GLOB dirs RELATIVE "${PROJECT_SOURCE_DIR}/sdf" - "${PROJECT_SOURCE_DIR}/sdf/*") - list(SORT dirs) - - # Add each sdf protocol to the sdf_path variable - foreach(dir ${dirs}) - if (IS_DIRECTORY ${PROJECT_SOURCE_DIR}/sdf/${dir}) - set(sdf_paths "${PROJECT_SOURCE_DIR}/sdf/${dir}:${sdf_paths}") - endif() - endforeach() - - # Set the SDF_PATH environment variable - list(APPEND _env_vars "SDF_PATH=${sdf_paths}") - - set_tests_properties(${BINARY_NAME} PROPERTIES - TIMEOUT 240 - ENVIRONMENT "${_env_vars}") - - if(PYTHONINTERP_FOUND) - # Check that the test produced a result and create a failure if it didn't. - # Guards against crashed and timed out tests. - add_test(check_${BINARY_NAME} ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/tools/check_test_ran.py - ${CMAKE_BINARY_DIR}/test_results/${BINARY_NAME}.xml) - endif() - - if(SDFORMAT_RUN_VALGRIND_TESTS AND VALGRIND_PROGRAM) - add_test(memcheck_${BINARY_NAME} ${VALGRIND_PROGRAM} --leak-check=full - --error-exitcode=1 --show-leak-kinds=all ${CMAKE_CURRENT_BINARY_DIR}/${BINARY_NAME}) - endif() - endforeach() - - set(GZ_BUILD_TESTS_EXTRA_EXE_SRCS "") -endmacro() - -################################################# -# Macro to setup supported compiler warnings -# Based on work of Florent Lamiraux, Thomas Moulard, JRL, CNRS/AIST. -include(CheckCXXCompilerFlag) - -macro(filter_valid_compiler_warnings) - foreach(flag ${ARGN}) - CHECK_CXX_COMPILER_FLAG(${flag} R${flag}) - if(${R${flag}}) - set(WARNING_CXX_FLAGS "${WARNING_CXX_FLAGS} ${flag}") - endif() - endforeach() -endmacro() - ################################################# # Copied from catkin/cmake/empy.cmake function(find_python_module module) diff --git a/cmake/SearchForStuff.cmake b/cmake/SearchForStuff.cmake index 54bcc61db..072aabf78 100644 --- a/cmake/SearchForStuff.cmake +++ b/cmake/SearchForStuff.cmake @@ -1,14 +1,8 @@ -include (FindPkgConfig) - -# Detect the architecture -include (${project_cmake_dir}/TargetArch.cmake) -target_architecture(ARCH) message(STATUS "Building for arch: ${ARCH}") ################################################# # Find tinyxml2. -list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules") -find_package(TinyXML2 REQUIRED) +ign_find_package(TINYXML2 REQUIRED) ################################################ # Find urdfdom parser. Logic: @@ -16,61 +10,36 @@ find_package(TinyXML2 REQUIRED) # 1. if USE_INTERNAL_URDF is unset, try to use system installation, fallback to internal copy # 2. if USE_INTERNAL_URDF is set to True, use the internal copy # 3. if USE_INTERNAL_URDF is set to False, force to search system installation, fail on error - -if (NOT PKG_CONFIG_FOUND) - if (NOT DEFINED USE_INTERNAL_URDF) - BUILD_WARNING("Couldn't find pkg-config for urdfdom, using internal copy") - set(USE_INTERNAL_URDF true) - elseif(NOT USE_INTERNAL_URDF) - BUILD_ERROR("Couldn't find pkg-config for urdfdom") - endif() -endif() - if (NOT DEFINED USE_INTERNAL_URDF OR NOT USE_INTERNAL_URDF) - # check for urdfdom with pkg-config - pkg_check_modules(URDF urdfdom>=1.0) - - if (NOT URDF_FOUND) - find_package(urdfdom QUIET) - if (urdfdom_FOUND) - set(URDF_INCLUDE_DIRS ${urdfdom_INCLUDE_DIRS}) - # ${urdfdom_LIBRARIES} already contains absolute library filenames - set(URDF_LIBRARY_DIRS "") - set(URDF_LIBRARIES ${urdfdom_LIBRARIES}) - elseif (NOT DEFINED USE_INTERNAL_URDF) - message(STATUS "Couldn't find urdfdom >= 1.0, using internal copy") - set(USE_INTERNAL_URDF true) + ign_find_package(IgnURDFDOM QUIET) + if (NOT IgnURDFDOM_FOUND) + if (NOT DEFINED USE_INTERNAL_URDF) + # fallback to internal urdf + set(USE_INTERNAL_URDF ON) else() - BUILD_ERROR("Couldn't find the urdfdom >= 1.0 system installation") + ign_build_error("Couldn't find the urdfdom >= 1.0 system installation") endif() - else() - # what am I doing here? pkg-config and cmake - set(URDF_INCLUDE_DIRS ${URDF_INCLUDEDIR}) - set(URDF_LIBRARY_DIRS ${URDF_LIBDIR}) endif() endif() +if (USE_INTERNAL_URDF) + message(STATUS "Using internal URDF") +endif() + ################################################# # Find ign command line utility: -find_package(ignition-tools) -if (IGNITION-TOOLS_BINARY_DIRS) - message(STATUS "Looking for ignition-tools-config.cmake - found") -else() - BUILD_WARNING ("ignition-tools not found, for command line utilities and for \ -generating aggregated SDFormat descriptions for sdformat.org, please install \ -ignition-tools.") -endif() +ign_find_package(ignition-tools) ################################################ # Find the Python interpreter for running the # check_test_ran.py script -find_package(PythonInterp 3 QUIET) +ign_find_package(PythonInterp VERSION 3 QUIET) ################################################ # Find psutil python package for memory tests find_python_module(psutil) if(NOT PY_PSUTIL) - BUILD_WARNING("Python psutil package not found. Memory leak tests will be skipped") + ign_build_warning("Python psutil package not found. Memory leak tests will be skipped") endif() ################################################ @@ -80,54 +49,26 @@ find_program(VALGRIND_PROGRAM NAMES valgrind PATH ${VALGRIND_ROOT}/bin) option(SDFORMAT_RUN_VALGRIND_TESTS "Run sdformat tests with Valgrind" FALSE) mark_as_advanced(SDFORMAT_RUN_VALGRIND_TESTS) if (SDFORMAT_RUN_VALGRIND_TESTS AND NOT VALGRIND_PROGRAM) - BUILD_WARNING("valgrind not found. Memory check tests will be skipped.") + ign_build_warning("valgrind not found. Memory check tests will be skipped.") endif() ################################################ # Find ruby executable to produce xml schemas find_program(RUBY ruby) if (NOT RUBY) - BUILD_ERROR ("Ruby version 1.9 is needed to build xml schemas") + ign_build_error ("Ruby version 1.9 is needed to build xml schemas") else() message(STATUS "Found ruby executable: ${RUBY}") endif() -################################################# -# Macro to check for visibility capability in compiler -# Original idea from: https://gitorious.org/ferric-cmake-stuff/ -macro (check_gcc_visibility) - include (CheckCXXCompilerFlag) - check_cxx_compiler_flag(-fvisibility=hidden GCC_SUPPORTS_VISIBILITY) -endmacro() - -######################################## -# Find ignition cmake2 -# Only for using the testing macros and creating the codecheck target, not -# really being use to configure the whole project -find_package(ignition-cmake2 2.3 REQUIRED) -set(IGN_CMAKE_VER ${ignition-cmake2_VERSION_MAJOR}) - ######################################## # Find ignition math # Set a variable for generating ProjectConfig.cmake -find_package(ignition-math6 6.8 QUIET) -if (NOT ignition-math6_FOUND) - message(STATUS "Looking for ignition-math6-config.cmake - not found") - BUILD_ERROR ("Missing: Ignition math (libignition-math6-dev)") -else() - set(IGN_MATH_VER ${ignition-math6_VERSION_MAJOR}) - message(STATUS "Looking for ignition-math${IGN_MATH_VER}-config.cmake - found") -endif() +ign_find_package(ignition-math6 VERSION 6.8 REQUIRED) +set(IGN_MATH_VER ${ignition-math6_VERSION_MAJOR}) ######################################## # Find ignition utils # Set a variable for generating ProjectConfig.cmake -find_package(ignition-utils1 QUIET) -if (NOT ignition-utils1_FOUND) - message(STATUS "Looking for ignition-utils1-config.cmake - not found") - BUILD_ERROR ("Missing: Ignition utils(libignition-utils1-dev)") -else() - set(IGN_UTILS_VER ${ignition-utils1_VERSION_MAJOR}) - message(STATUS "Looking for ignition-utils${IGN_UTILS_VER}-config.cmake - found") -endif() - +ign_find_package(ignition-utils1 REQUIRED) +set(IGN_UTILS_VER ${ignition-utils1_VERSION_MAJOR}) diff --git a/cmake/TargetArch.cmake b/cmake/TargetArch.cmake deleted file mode 100644 index d50073c82..000000000 --- a/cmake/TargetArch.cmake +++ /dev/null @@ -1,158 +0,0 @@ -# Copyright (c) 2012 Petroules Corporation. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# Redistributions of source code must retain the above copyright notice, this -# list of conditions and the following disclaimer. Redistributions in binary -# form must reproduce the above copyright notice, this list of conditions and -# the following disclaimer in the documentation and/or other materials -# provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -# Based on the Qt 5 processor detection code, so should be very accurate -# https://qt.gitorious.org/qt/qtbase/blobs/master/src/corelib/global/qprocessordetection.h -# Currently handles arm (v5, v6, v7), x86 (32/64), ia64, and ppc (32/64) - -# Regarding POWER/PowerPC, just as is noted in the Qt source, -# "There are many more known variants/revisions that we do not handle/detect." - - - -set(archdetect_c_code " -#if defined(__arm__) || defined(__TARGET_ARCH_ARM) - #if defined(__ARM_ARCH_7__) \\ - || defined(__ARM_ARCH_7A__) \\ - || defined(__ARM_ARCH_7R__) \\ - || defined(__ARM_ARCH_7M__) \\ - || (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 7) - #error cmake_ARCH armv7 - #elif defined(__ARM_ARCH_6__) \\ - || defined(__ARM_ARCH_6J__) \\ - || defined(__ARM_ARCH_6T2__) \\ - || defined(__ARM_ARCH_6Z__) \\ - || defined(__ARM_ARCH_6K__) \\ - || defined(__ARM_ARCH_6ZK__) \\ - || defined(__ARM_ARCH_6M__) \\ - || (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 6) - #error cmake_ARCH armv6 - #elif defined(__ARM_ARCH_5TEJ__) \\ - || (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 5) - #error cmake_ARCH armv5 - #else - #error cmake_ARCH arm - #endif -#elif defined(__i386) || defined(__i386__) || defined(_M_IX86) - #error cmake_ARCH i386 -#elif defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(_M_X64) - #error cmake_ARCH x86_64 -#elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64) - #error cmake_ARCH ia64 -#elif defined(__ppc__) || defined(__ppc) || defined(__powerpc__) \\ - || defined(_ARCH_COM) || defined(_ARCH_PWR) || defined(_ARCH_PPC) \\ - || defined(_M_MPPC) || defined(_M_PPC) - #if defined(__ppc64__) || defined(__powerpc64__) || defined(__64BIT__) - #error cmake_ARCH ppc64 - #else - #error cmake_ARCH ppc - #endif -#endif - -#error cmake_ARCH unknown -") - -# Set ppc_support to TRUE before including this file or ppc and ppc64 -# will be treated as invalid architectures since they are no longer supported by Apple - -function(target_architecture output_var) - if(APPLE AND CMAKE_OSX_ARCHITECTURES) - # On OS X we use CMAKE_OSX_ARCHITECTURES *if* it was set - # First let's normalize the order of the values - - # Note that it's not possible to compile PowerPC applications if you are using - # the OS X SDK version 10.6 or later - you'll need 10.4/10.5 for that, so we - # disable it by default - # See this page for more information: - # http://stackoverflow.com/questions/5333490/how-can-we-restore-ppc-ppc64-as-well-as-full-10-4-10-5-sdk-support-to-xcode-4 - - # Architecture defaults to i386 or ppc on OS X 10.5 and earlier, depending on the CPU type detected at runtime. - # On OS X 10.6+ the default is x86_64 if the CPU supports it, i386 otherwise. - - foreach(osx_arch ${CMAKE_OSX_ARCHITECTURES}) - if("${osx_arch}" STREQUAL "ppc" AND ppc_support) - set(osx_arch_ppc TRUE) - elseif("${osx_arch}" STREQUAL "i386") - set(osx_arch_i386 TRUE) - elseif("${osx_arch}" STREQUAL "x86_64") - set(osx_arch_x86_64 TRUE) - elseif("${osx_arch}" STREQUAL "ppc64" AND ppc_support) - set(osx_arch_ppc64 TRUE) - else() - message(FATAL_ERROR "Invalid OS X arch name: ${osx_arch}") - endif() - endforeach() - - # Now add all the architectures in our normalized order - if(osx_arch_ppc) - list(APPEND ARCH ppc) - endif() - - if(osx_arch_i386) - list(APPEND ARCH i386) - endif() - - if(osx_arch_x86_64) - list(APPEND ARCH x86_64) - endif() - - if(osx_arch_ppc64) - list(APPEND ARCH ppc64) - endif() - else() - file(WRITE "${CMAKE_BINARY_DIR}/arch.c" "${archdetect_c_code}") - - enable_language(C) - - # Detect the architecture in a rather creative way... - # This compiles a small C program which is a series of ifdefs that selects a - # particular #error preprocessor directive whose message string contains the - # target architecture. The program will always fail to compile (both because - # file is not a valid C program, and obviously because of the presence of the - # #error preprocessor directives... but by exploiting the preprocessor in this - # way, we can detect the correct target architecture even when cross-compiling, - # since the program itself never needs to be run (only the compiler/preprocessor) - try_run( - run_result_unused - compile_result_unused - "${CMAKE_BINARY_DIR}" - "${CMAKE_BINARY_DIR}/arch.c" - COMPILE_OUTPUT_VARIABLE ARCH - CMAKE_FLAGS CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} - ) - - # Parse the architecture name from the compiler output - string(REGEX MATCH "cmake_ARCH ([a-zA-Z0-9_]+)" ARCH "${ARCH}") - - # Get rid of the value marker leaving just the architecture name - string(REPLACE "cmake_ARCH " "" ARCH "${ARCH}") - - # If we are compiling with an unknown architecture this variable should - # already be set to "unknown" but in the case that it's empty (i.e. due - # to a typo in the code), then set it to unknown - if (NOT ARCH) - set(ARCH unknown) - endif() - endif() - - set(${output_var} "${ARCH}" PARENT_SCOPE) -endfunction() diff --git a/cmake/cmake_uninstall.cmake.in b/cmake/cmake_uninstall.cmake.in deleted file mode 100644 index 2037e3653..000000000 --- a/cmake/cmake_uninstall.cmake.in +++ /dev/null @@ -1,21 +0,0 @@ -if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") - message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") -endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") - -file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) -string(REGEX REPLACE "\n" ";" files "${files}") -foreach(file ${files}) - message(STATUS "Uninstalling $ENV{DESTDIR}${file}") - if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") - exec_program( - "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" - OUTPUT_VARIABLE rm_out - RETURN_VALUE rm_retval - ) - if(NOT "${rm_retval}" STREQUAL 0) - message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") - endif(NOT "${rm_retval}" STREQUAL 0) - else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") - message(STATUS "File $ENV{DESTDIR}${file} does not exist.") - endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") -endforeach(file) diff --git a/cmake/cpack_options.cmake.in b/cmake/cpack_options.cmake.in deleted file mode 100644 index b5cb6d5c1..000000000 --- a/cmake/cpack_options.cmake.in +++ /dev/null @@ -1,23 +0,0 @@ -set(CPACK_PACKAGE_NAME "@PROJECT_NAME_NO_VERSION@") -set(CPACK_PACKAGE_VENDOR "sdformat.org") -set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Scene Description Format (SDF)") -set(CPACK_PACKAGE_INSTALL_DIRECTORY "@PROJECT_NAME_NO_VERSION_LOWER@") -set(CPACK_RESOURCE_FILE_LICENSE "@CMAKE_CURRENT_SOURCE_DIR@/LICENSE") -set(CPACK_RESOURCE_FILE_README "@CMAKE_CURRENT_SOURCE_DIR@/README.md") -set(CPACK_PACKAGE_DESCRIPTION_FILE "@CMAKE_CURRENT_SOURCE_DIR@/README.md") -set(CPACK_PACKAGE_MAINTAINER "Nate Koenig ") -set(CPACK_PACKAGE_CONTACT "Nate Koenig ") - -set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "@DPKG_ARCH@") -set(CPACK_DEBIAN_PACKAGE_DEPENDS "@DEBIAN_PACKAGE_DEPENDS@") -set(CPACK_DEBIAN_PACKAGE_SECTION "devel") -set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional") -set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) -set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "Format and parser for scene description files.") - -set(CPACK_RPM_PACKAGE_ARCHITECTURE "@DPKG_ARCH@") -set(CPACK_RPM_PACKAGE_REQUIRES "@DEBIAN_PACKAGE_DEPENDS@") -set(CPACK_RPM_PACKAGE_DESCRIPTION "Format and parser for scene description files.") - -set (CPACK_PACKAGE_FILE_NAME "@PROJECT_NAME_NO_VERSION_LOWER@-@SDF_VERSION_FULL@") -set (CPACK_SOURCE_PACKAGE_FILE_NAME "@PROJECT_NAME_NO_VERSION_LOWER@-@SDF_VERSION_FULL@") diff --git a/cmake/sdf_config.cmake.in b/cmake/sdf_config.cmake.in deleted file mode 100644 index eea1d4022..000000000 --- a/cmake/sdf_config.cmake.in +++ /dev/null @@ -1,44 +0,0 @@ -# We explicitly set the desired cmake version to ensure that the policy settings -# of users or of toolchains do not result in the wrong behavior for our modules. -# Note that the call to find_package(~) will PUSH a new policy stack before -# taking on these version settings, and then that stack will POP after the -# find_package(~) has exited, so this will not affect the cmake policy settings -# of a caller. -cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) - -if(@PKG_NAME@_CONFIG_INCLUDED) - return() -endif() -set(@PKG_NAME@_CONFIG_INCLUDED TRUE) - -@PACKAGE_INIT@ - -if(NOT TARGET @sdf_import_target_name@) - include("${CMAKE_CURRENT_LIST_DIR}/@sdf_target_output_filename@") -endif() - -list(APPEND @PKG_NAME@_INCLUDE_DIRS "${PACKAGE_PREFIX_DIR}/include/sdformat-@SDF_VERSION@") - -list(APPEND @PKG_NAME@_CFLAGS "-I${PACKAGE_PREFIX_DIR}/include/sdformat-@SDF_VERSION@") -if (NOT WIN32) - list(APPEND @PKG_NAME@_CXX_FLAGS "${@PKG_NAME@_CFLAGS} -std=c++17") -endif() - -list(APPEND @PKG_NAME@_LIBRARY_DIRS "${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_LIBDIR@") - -set(@PKG_NAME@_LIBRARIES @sdf_import_target_name@) - -# These variables are used by ignition-cmake to automatically configure the -# pkgconfig files for ignition projects. -set(@PROJECT_NAME_LOWER@_PKGCONFIG_ENTRY "@PROJECT_NAME_LOWER@") -set(@PROJECT_NAME_LOWER@_PKGCONFIG_TYPE PKGCONFIG_REQUIRES) - -find_package(ignition-math@IGN_MATH_VER@) -list(APPEND @PKG_NAME@_INCLUDE_DIRS ${IGNITION-MATH_INCLUDE_DIRS}) -list(APPEND @PKG_NAME@_LIBRARY_DIRS ${IGNITION-MATH_LIBRARY_DIRS}) - -find_package(ignition-utils@IGN_UTILS_VER@) -list(APPEND @PKG_NAME@_INCLUDE_DIRS ${IGNITION-UTILS_INCLUDE_DIRS}) -list(APPEND @PKG_NAME@_LIBRARY_DIRS ${IGNITION-UTILS_LIBRARY_DIRS}) - -list(APPEND @PKG_NAME@_LDFLAGS "-L${PACKAGE_PREFIX_DIR}/@LIB_INSTALL_DIR@") diff --git a/cmake/sdf_cpack.cmake b/cmake/sdf_cpack.cmake deleted file mode 100644 index 6267aae34..000000000 --- a/cmake/sdf_cpack.cmake +++ /dev/null @@ -1,25 +0,0 @@ -################################################################################ -#Find available package generators - -# DEB -if ("${CMAKE_SYSTEM}" MATCHES "Linux") - find_program(DPKG_PROGRAM dpkg) - if (EXISTS ${DPKG_PROGRAM}) - list (APPEND CPACK_GENERATOR "DEB") - endif(EXISTS ${DPKG_PROGRAM}) - - find_program(RPMBUILD_PROGRAM rpmbuild) -endif() - -list (APPEND CPACK_SOURCE_GENERATOR "TBZ2") -list (APPEND CPACK_SOURCE_GENERATOR "ZIP") -list (APPEND CPACK_SOURCE_IGNORE_FILES ";TODO;/.hg/;.swp$;/build/") - -include (InstallRequiredSystemLibraries) - -#execute_process(COMMAND dpkg --print-architecture _NPROCE) -set (DEBIAN_PACKAGE_DEPENDS "libtinyxml-dev") - -set (RPM_PACKAGE_DEPENDS "libtinyxml-dev") - -set (SDF_CPACK_CFG_FILE "${PROJECT_BINARY_DIR}/cpack_options.cmake") diff --git a/cmake/sdformat_pc.in b/cmake/sdformat_pc.in deleted file mode 100644 index 621509b53..000000000 --- a/cmake/sdformat_pc.in +++ /dev/null @@ -1,10 +0,0 @@ -prefix=${pcfiledir}/@PC_CONFIG_RELATIVE_PATH_TO_PREFIX@ -libdir=${prefix}/@LIB_INSTALL_DIR@ -includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ - -Name: SDF -Description: Robot Modeling Language (SDF) -Version: @SDF_VERSION_FULL@ -Requires: ignition-math@IGN_MATH_VER@, ignition-utils@IGN_UTILS_VER@ -Libs: -L${libdir} -lsdformat@SDF_MAJOR_VERSION@ -CFlags: -I${includedir}/sdformat-@SDF_VERSION@ -std=c++17 diff --git a/conf/CMakeLists.txt b/conf/CMakeLists.txt index 001e28ee5..388c30cc1 100644 --- a/conf/CMakeLists.txt +++ b/conf/CMakeLists.txt @@ -1,23 +1,23 @@ # Used only for internal testing. -set(ign_library_path "${CMAKE_BINARY_DIR}/test/lib/ruby/ignition/cmd${sdf_target}") +set(ign_library_path "${CMAKE_BINARY_DIR}/test/lib/ruby/ignition/cmd${PROJECT_NAME}") # Generate a configuration file for internal testing. # Note that the major version of the library is included in the name. # Ex: sdformat0.yaml configure_file( "${PROJECT_NAME_NO_VERSION_LOWER}.yaml.in" - "${CMAKE_BINARY_DIR}/test/conf/${sdf_target}.yaml" @ONLY) + "${CMAKE_BINARY_DIR}/test/conf/${PROJECT_NAME}.yaml" @ONLY) # Used for the installed version. -set(ign_library_path "${CMAKE_INSTALL_PREFIX}/lib/ruby/ignition/cmd${sdf_target}") +set(ign_library_path "${CMAKE_INSTALL_PREFIX}/lib/ruby/ignition/cmd${PROJECT_NAME}") # Generate the configuration file that is installed. # Note that the major version of the library is included in the name. # Ex: sdformat0.yaml configure_file( - "${PROJECT_NAME_NO_VERSION_LOWER}.yaml.in" - "${CMAKE_CURRENT_BINARY_DIR}/${sdf_target}.yaml" @ONLY) + "${CMAKE_SOURCE_DIR}/conf/${PROJECT_NAME_NO_VERSION_LOWER}.yaml.in" + "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.yaml" @ONLY) # Install the yaml configuration files in an unversioned location. -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${sdf_target}.yaml +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.yaml DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/ignition/) diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 019149959..66d4caa6a 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -15,7 +15,7 @@ if (DOXYGEN_FOUND) ${CMAKE_BINARY_DIR}/doxygen/html/search COMMAND make -C ${CMAKE_BINARY_DIR}/doxygen/latex COMMAND mv ${CMAKE_BINARY_DIR}/doxygen/latex/refman.pdf - ${CMAKE_BINARY_DIR}/doxygen/latex/sdf-${SDF_VERSION_FULL}.pdf + ${CMAKE_BINARY_DIR}/doxygen/latex/sdf-${PROJECT_VERSION_FULL}.pdf COMMENT "Generating API documentation with Doxygen" VERBATIM) endif() diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 39caedb85..995fa11ad 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -4,11 +4,8 @@ find_package(sdformat13 REQUIRED) set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17") -include_directories(${SDFormat_INCLUDE_DIRS}) -link_directories(${SDFormat_LIBRARY_DIRS}) - add_executable(simple simple.cc) -target_link_libraries(simple ${SDFormat_LIBRARIES}) +target_link_libraries(simple sdformat13) add_executable(dom dom.cc) -target_link_libraries(dom ${SDFormat_LIBRARIES}) +target_link_libraries(dom sdformat13) diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt new file mode 100644 index 000000000..722dbe56c --- /dev/null +++ b/include/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(sdf) diff --git a/include/sdf/CMakeLists.txt b/include/sdf/CMakeLists.txt index e1422b316..94f57dcfe 100644 --- a/include/sdf/CMakeLists.txt +++ b/include/sdf/CMakeLists.txt @@ -1,73 +1,8 @@ -include (${sdf_cmake_dir}/SDFUtils.cmake) - -set (headers - Actor.hh - AirPressure.hh - Altimeter.hh - Assert.hh - Atmosphere.hh - Box.hh - Camera.hh - Capsule.hh - Collision.hh - Console.hh - Cylinder.hh - Element.hh - Ellipsoid.hh - Error.hh - Exception.hh - Filesystem.hh - ForceTorque.hh - Frame.hh - Geometry.hh - Gui.hh - Heightmap.hh - Imu.hh - InterfaceElements.hh - InterfaceFrame.hh - InterfaceJoint.hh - InterfaceLink.hh - InterfaceModel.hh - InterfaceModelPoseGraph.hh - Joint.hh - JointAxis.hh - Lidar.hh - Light.hh - Link.hh - Magnetometer.hh - Material.hh - Mesh.hh - Model.hh - NavSat.hh - Noise.hh - Param.hh - parser.hh - ParserConfig.hh - ParticleEmitter.hh - Pbr.hh - Physics.hh - Plane.hh - PrintConfig.hh - Root.hh - Scene.hh - SDFImpl.hh - SemanticPose.hh - Sensor.hh - Sky.hh - Sphere.hh - Surface.hh - Types.hh - system_util.hh - Visual.hh - World.hh +# Exlcude some files so that they are not added to the master header. +ign_install_all_headers(EXCLUDE_FILES sdf.hh sdf_config.h) +install( + FILES + sdf.hh + sdf_config.h + DESTINATION ${IGN_INCLUDE_INSTALL_DIR_FULL}/${PROJECT_INCLUDE_DIR} ) - -set (sdf_headers "" CACHE INTERNAL "SDF headers" FORCE) -foreach (hdr ${headers}) - set(sdf_headers "${sdf_headers}#include \n") -endforeach() -configure_file (${CMAKE_CURRENT_SOURCE_DIR}/sdf.hh.in - ${CMAKE_CURRENT_BINARY_DIR}/sdf.hh) - -sdf_install_includes("" ${headers} - ${CMAKE_CURRENT_BINARY_DIR}/sdf.hh) diff --git a/cmake/sdf_config.h.in b/include/sdf/config.hh.in similarity index 61% rename from cmake/sdf_config.h.in rename to include/sdf/config.hh.in index 17351e009..24534394a 100644 --- a/cmake/sdf_config.h.in +++ b/include/sdf/config.hh.in @@ -1,5 +1,8 @@ /* config.h. Generated by CMake for @PROJECT_NAME@. */ +#ifndef SDF_CONFIG_HH_ +#define SDF_CONFIG_HH_ + /* Protocol version */ #define SDF_PROTOCOL_VERSION "${SDF_PROTOCOL_VERSION}" /* \deprecated SDF_VERSION is deprecated. Please @@ -11,17 +14,18 @@ #define SDF_VERSION "${SDF_PROTOCOL_VERSION}" /* Package version number */ -#define SDF_MAJOR_VERSION ${SDF_MAJOR_VERSION} -#define SDF_MINOR_VERSION ${SDF_MINOR_VERSION} -#define SDF_PATCH_VERSION ${SDF_PATCH_VERSION} +#define SDF_MAJOR_VERSION ${PROJECT_VERSION_MAJOR} +#define SDF_MINOR_VERSION ${PROJECT_VERSION_MINOR} +#define SDF_PATCH_VERSION ${PROJECT_VERSION_PATCH} -#define SDF_MAJOR_VERSION_STR "${SDF_MAJOR_VERSION}" -#define SDF_MINOR_VERSION_STR "${SDF_MINOR_VERSION}" -#define SDF_PATCH_VERSION_STR "${SDF_PATCH_VERSION}" +#define SDF_MAJOR_VERSION_STR "${PROJECT_VERSION_MAJOR}" +#define SDF_MINOR_VERSION_STR "${PROJECT_VERSION_MINOR}" +#define SDF_PATCH_VERSION_STR "${PROJECT_VERSION_PATCH}" -#define SDF_PKG_VERSION "${SDF_VERSION}" -#define SDF_VERSION_FULL "${SDF_VERSION_FULL}" -#define SDF_VERSION_NAMESPACE v${SDF_MAJOR_VERSION} +#define SDF_PKG_VERSION "${PROJECT_VERSION}" +#define SDF_VERSION_FULL "${PROJECT_VERSION_FULL}" +#define SDF_VERSION_NAME ${PROJECT_VERSION_NAME} +#define SDF_VERSION_NAMESPACE v${PROJECT_VERSION_MAJOR} #define SDF_VERSION_HEADER "Simulation Description Format (SDF), version ${SDF_PROTOCOL_VERSION}\nCopyright (C) 2014 Open Source Robotics Foundation.\nReleased under the Apache 2 License.\nhttp://gazebosim.org/sdf\n\n" @@ -33,4 +37,6 @@ #cmakedefine SDFORMAT_DISABLE_CONSOLE_LOGFILE 1 #define SDF_SHARE_PATH "${CMAKE_INSTALL_FULL_DATAROOTDIR}/" -#define SDF_VERSION_PATH "${CMAKE_INSTALL_FULL_DATAROOTDIR}/sdformat${SDF_MAJOR_VERSION}/${SDF_PKG_VERSION}" +#define SDF_VERSION_PATH "${CMAKE_INSTALL_FULL_DATAROOTDIR}/sdformat${PROJECT_VERSION_MAJOR}" + +#endif // SDF_CONFIG_HH_ diff --git a/include/sdf/sdf.hh b/include/sdf/sdf.hh new file mode 100644 index 000000000..1421078c5 --- /dev/null +++ b/include/sdf/sdf.hh @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2021 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 SDF_SDF_HH_ +#define SDF_SDF_HH_ + +// TODO: deprecate this header? +// #pragma message("sdf/sdf.hh is deprecated, use sdformat.hh instead") + +#include + +#endif diff --git a/include/sdf/sdf.hh.in b/include/sdf/sdf.hh.in deleted file mode 100644 index 11fb7d63b..000000000 --- a/include/sdf/sdf.hh.in +++ /dev/null @@ -1,3 +0,0 @@ -// Automatically generated -${sdf_headers} -#include diff --git a/include/sdf/sdf_config.h b/include/sdf/sdf_config.h new file mode 100644 index 000000000..03798db07 --- /dev/null +++ b/include/sdf/sdf_config.h @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2021 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 SDF_SDF_CONFIG_H_ +#define SDF_SDF_CONFIG_H_ + +// TODO: deprecate this header? +// #pragma message("sdf/sdf_config.h is deprecated, use sdf/config.hh instead") + +#include + +#endif diff --git a/sdf/1.0/CMakeLists.txt b/sdf/1.0/CMakeLists.txt index 1695588b1..dd62ae21c 100644 --- a/sdf/1.0/CMakeLists.txt +++ b/sdf/1.0/CMakeLists.txt @@ -27,4 +27,4 @@ set (sdfs world.sdf ) -install(FILES ${sdfs} DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/sdformat${SDF_MAJOR_VERSION}/1.0/) +install(FILES ${sdfs} DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/sdformat${PROJECT_VERSION_MAJOR}/1.0/) diff --git a/sdf/1.2/CMakeLists.txt b/sdf/1.2/CMakeLists.txt index a37e84191..051e49e55 100644 --- a/sdf/1.2/CMakeLists.txt +++ b/sdf/1.2/CMakeLists.txt @@ -28,4 +28,4 @@ set (sdfs world.sdf ) -install(FILES ${sdfs} DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/sdformat${SDF_MAJOR_VERSION}/1.2) +install(FILES ${sdfs} DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/sdformat${PROJECT_VERSION_MAJOR}/1.2) diff --git a/sdf/1.3/CMakeLists.txt b/sdf/1.3/CMakeLists.txt index b737f0e50..9325a7e19 100644 --- a/sdf/1.3/CMakeLists.txt +++ b/sdf/1.3/CMakeLists.txt @@ -29,4 +29,4 @@ set (sdfs world.sdf ) -install(FILES ${sdfs} DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/sdformat${SDF_MAJOR_VERSION}/1.3) +install(FILES ${sdfs} DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/sdformat${PROJECT_VERSION_MAJOR}/1.3) diff --git a/sdf/1.4/CMakeLists.txt b/sdf/1.4/CMakeLists.txt index a59f4ea68..657bd085e 100644 --- a/sdf/1.4/CMakeLists.txt +++ b/sdf/1.4/CMakeLists.txt @@ -44,4 +44,4 @@ set (sdfs world.sdf ) -install(FILES ${sdfs} DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/sdformat${SDF_MAJOR_VERSION}/1.4) +install(FILES ${sdfs} DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/sdformat${PROJECT_VERSION_MAJOR}/1.4) diff --git a/sdf/1.5/CMakeLists.txt b/sdf/1.5/CMakeLists.txt index 60fd6a15a..89e721573 100644 --- a/sdf/1.5/CMakeLists.txt +++ b/sdf/1.5/CMakeLists.txt @@ -76,5 +76,5 @@ add_custom_target(schema1_5 ALL DEPENDS ${SDF_SCHEMA}) set_source_files_properties(${SDF_SCHEMA} PROPERTIES GENERATED TRUE) -install(FILES 1_4.convert ${sdfs} DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/sdformat${SDF_MAJOR_VERSION}/1.5) -install(FILES ${SDF_SCHEMA} DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/sdformat${SDF_MAJOR_VERSION}/1.5) +install(FILES 1_4.convert ${sdfs} DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/sdformat${PROJECT_VERSION_MAJOR}/1.5) +install(FILES ${SDF_SCHEMA} DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/sdformat${PROJECT_VERSION_MAJOR}/1.5) diff --git a/sdf/1.6/CMakeLists.txt b/sdf/1.6/CMakeLists.txt index fe972e4c5..f386b30bf 100644 --- a/sdf/1.6/CMakeLists.txt +++ b/sdf/1.6/CMakeLists.txt @@ -80,5 +80,5 @@ add_custom_target(schema1_6 ALL DEPENDS ${SDF_SCHEMA}) set_source_files_properties(${SDF_SCHEMA} PROPERTIES GENERATED TRUE) -install(FILES 1_5.convert ${sdfs} DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/sdformat${SDF_MAJOR_VERSION}/1.6) -install(FILES ${SDF_SCHEMA} DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/sdformat${SDF_MAJOR_VERSION}/1.6) +install(FILES 1_5.convert ${sdfs} DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/sdformat${PROJECT_VERSION_MAJOR}/1.6) +install(FILES ${SDF_SCHEMA} DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/sdformat${PROJECT_VERSION_MAJOR}/1.6) diff --git a/sdf/1.7/CMakeLists.txt b/sdf/1.7/CMakeLists.txt index 516a7874b..4167a3b97 100644 --- a/sdf/1.7/CMakeLists.txt +++ b/sdf/1.7/CMakeLists.txt @@ -80,5 +80,5 @@ add_custom_target(schema1_7 ALL DEPENDS ${SDF_SCHEMA}) set_source_files_properties(${SDF_SCHEMA} PROPERTIES GENERATED TRUE) -install(FILES 1_6.convert ${sdfs} DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/sdformat${SDF_MAJOR_VERSION}/1.7) -install(FILES ${SDF_SCHEMA} DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/sdformat${SDF_MAJOR_VERSION}/1.7) +install(FILES 1_6.convert ${sdfs} DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/sdformat${PROJECT_VERSION_MAJOR}/1.7) +install(FILES ${SDF_SCHEMA} DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/sdformat${PROJECT_VERSION_MAJOR}/1.7) diff --git a/sdf/1.8/CMakeLists.txt b/sdf/1.8/CMakeLists.txt index d074806f5..30555b39a 100644 --- a/sdf/1.8/CMakeLists.txt +++ b/sdf/1.8/CMakeLists.txt @@ -82,5 +82,5 @@ add_custom_target(schema1_8 ALL DEPENDS ${SDF_SCHEMA}) set_source_files_properties(${SDF_SCHEMA} PROPERTIES GENERATED TRUE) -install(FILES 1_7.convert ${sdfs} DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/sdformat${SDF_MAJOR_VERSION}/1.8) -install(FILES ${SDF_SCHEMA} DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/sdformat${SDF_MAJOR_VERSION}/1.8) +install(FILES 1_7.convert ${sdfs} DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/sdformat${PROJECT_VERSION_MAJOR}/1.8) +install(FILES ${SDF_SCHEMA} DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/sdformat${PROJECT_VERSION_MAJOR}/1.8) diff --git a/sdf/1.9/CMakeLists.txt b/sdf/1.9/CMakeLists.txt index 209d63043..7778acafd 100644 --- a/sdf/1.9/CMakeLists.txt +++ b/sdf/1.9/CMakeLists.txt @@ -82,5 +82,5 @@ add_custom_target(schema1_9 ALL DEPENDS ${SDF_SCHEMA}) set_source_files_properties(${SDF_SCHEMA} PROPERTIES GENERATED TRUE) -install(FILES 1_8.convert ${sdfs} DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/sdformat${SDF_MAJOR_VERSION}/1.9) -install(FILES ${SDF_SCHEMA} DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/sdformat${SDF_MAJOR_VERSION}/1.9) +install(FILES 1_8.convert ${sdfs} DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/sdformat${PROJECT_VERSION_MAJOR}/1.9) +install(FILES ${SDF_SCHEMA} DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/sdformat${PROJECT_VERSION_MAJOR}/1.9) diff --git a/sdf/CMakeLists.txt b/sdf/CMakeLists.txt index 9ce942840..bae97a640 100644 --- a/sdf/CMakeLists.txt +++ b/sdf/CMakeLists.txt @@ -40,5 +40,5 @@ if (IGNITION-TOOLS_BINARY_DIRS) COMMENT "Generating full description for spec ${desc_ver}" VERBATIM) endforeach() - add_custom_target(sdf_descriptions DEPENDS ${description_targets} ${sdf_target}) + add_custom_target(sdf_descriptions DEPENDS ${description_targets} ${PROJECT_NAME}) endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1e3c67eb2..365eb1e90 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,13 +1,5 @@ include (${sdf_cmake_dir}/SDFUtils.cmake) -link_directories( - ${PROJECT_BINARY_DIR}/test -) - -if (NOT USE_INTERNAL_URDF) - link_directories(${URDF_LIBRARY_DIRS}) -endif() - set (sources Actor.cc AirPressure.cc @@ -76,10 +68,8 @@ set (sources World.cc XmlUtils.cc ) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}) if (USE_INTERNAL_URDF) - include_directories(${CMAKE_CURRENT_SOURCE_DIR}/urdf) set(sources ${sources} urdf/urdf_parser/model.cpp urdf/urdf_parser/link.cpp @@ -89,8 +79,6 @@ if (USE_INTERNAL_URDF) urdf/urdf_parser/urdf_model_state.cpp urdf/urdf_parser/urdf_sensor.cpp urdf/urdf_parser/world.cpp) -else() - include_directories(${URDF_INCLUDE_DIRS}) endif() if (BUILD_SDF_TEST) @@ -155,103 +143,116 @@ if (BUILD_SDF_TEST) ) endif() - include_directories(${PROJECT_SOURCE_DIR}/test) - sdf_build_tests(${gtest_sources}) - - if (TARGET UNIT_ign_TEST) - # Link the libraries that we always need. - target_link_libraries("UNIT_ign_TEST" - PUBLIC - ignition-cmake${IGN_CMAKE_VER}::utilities - ) + if (NOT WIN32) + # set(SDF_BUILD_TESTS_EXTRA_EXE_SRCS Utils.cc) + set(gtest_sources ${gtest_sources} Utils_TEST.cc) endif() if (NOT WIN32) - set(SDF_BUILD_TESTS_EXTRA_EXE_SRCS Utils.cc) - sdf_build_tests(Utils_TEST.cc) + # set(SDF_BUILD_TESTS_EXTRA_EXE_SRCS XmlUtils.cc) + set(gtest_sources ${gtest_sources} XmlUtils_TEST.cc) endif() if (NOT WIN32) - set(SDF_BUILD_TESTS_EXTRA_EXE_SRCS XmlUtils.cc) - sdf_build_tests(XmlUtils_TEST.cc) - target_link_libraries(UNIT_XmlUtils_TEST PRIVATE - ${TinyXML2_LIBRARIES}) + # set(SDF_BUILD_TESTS_EXTRA_EXE_SRCS FrameSemantics.cc) + set(gtest_sources ${gtest_sources} FrameSemantics_TEST.cc) endif() if (NOT WIN32) - set(SDF_BUILD_TESTS_EXTRA_EXE_SRCS FrameSemantics.cc) - sdf_build_tests(FrameSemantics_TEST.cc) + # set(SDF_BUILD_TESTS_EXTRA_EXE_SRCS Converter.cc EmbeddedSdf.cc XmlUtils.cc) + set(gtest_sources ${gtest_sources} Converter_TEST.cc) endif() if (NOT WIN32) - set(SDF_BUILD_TESTS_EXTRA_EXE_SRCS Converter.cc EmbeddedSdf.cc XmlUtils.cc) - sdf_build_tests(Converter_TEST.cc) - target_link_libraries(UNIT_Converter_TEST PRIVATE - ${TinyXML2_LIBRARIES}) + # set(SDF_BUILD_TESTS_EXTRA_EXE_SRCS SDFExtension.cc parser_urdf.cc XmlUtils.cc) + set(gtest_sources ${gtest_sources} parser_urdf_TEST.cc) endif() if (NOT WIN32) - set(SDF_BUILD_TESTS_EXTRA_EXE_SRCS SDFExtension.cc parser_urdf.cc XmlUtils.cc) - sdf_build_tests(parser_urdf_TEST.cc) + # set(SDF_BUILD_TESTS_EXTRA_EXE_SRCS ParamPassing.cc XmlUtils.cc parser.cc + # parser_urdf.cc FrameSemantics.cc Converter.cc EmbeddedSdf.cc SDFExtension.cc Utils.cc) + set(gtest_sources ${gtest_sources} ParamPassing_TEST.cc) + endif() + + ign_build_tests( + TYPE UNIT + SOURCES ${gtest_sources} + # FIXME: This adds dependencies to ALL tests. + INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/test + ) + + if (TARGET UNIT_ign_TEST) + target_link_libraries(UNIT_ign_TEST ignition-cmake${IGN_CMAKE_VER}::utilities) + endif() + + if (TARGET UNIT_XmlUtils_TEST) + target_link_libraries(UNIT_XmlUtils_TEST ${TINYXML2_LIBRARIES}) + endif() + + if (TARGET UNIT_Converter_TEST) + target_link_libraries(UNIT_Converter_TEST ${TINYXML2_LIBRARIES}) + endif() + + if (TARGET UNIT_parser_urdf_TEST) if (NOT USE_INTERNAL_URDF) target_compile_options(UNIT_parser_urdf_TEST PRIVATE ${URDF_CFLAGS}) if (${CMAKE_VERSION} VERSION_GREATER 3.13) target_link_options(UNIT_parser_urdf_TEST PRIVATE ${URDF_LDFLAGS}) endif() - target_link_libraries(UNIT_parser_urdf_TEST PRIVATE ${URDF_LIBRARIES}) + target_link_libraries(UNIT_parser_urdf_TEST IgnURDFDOM::IgnURDFDOM) endif() - target_link_libraries(UNIT_parser_urdf_TEST PRIVATE - ${TinyXML2_LIBRARIES}) + target_link_libraries(UNIT_parser_urdf_TEST ${TINYXML2_LIBRARIES}) endif() - if (NOT WIN32) - set(SDF_BUILD_TESTS_EXTRA_EXE_SRCS ParamPassing.cc XmlUtils.cc parser.cc - parser_urdf.cc FrameSemantics.cc Converter.cc EmbeddedSdf.cc SDFExtension.cc Utils.cc) - sdf_build_tests(ParamPassing_TEST.cc) + if (TARGET UNIT_ParamPassing_TEST) if (NOT USE_INTERNAL_URDF) target_compile_options(UNIT_ParamPassing_TEST PRIVATE ${URDF_CFLAGS}) if (${CMAKE_VERSION} VERSION_GREATER 3.13) target_link_options(UNIT_ParamPassing_TEST PRIVATE ${URDF_LDFLAGS}) endif() - target_link_libraries(UNIT_ParamPassing_TEST PRIVATE ${URDF_LIBRARIES}) + target_link_libraries(UNIT_ParamPassing_TEST IgnURDFDOM::IgnURDFDOM) endif() - target_link_libraries(UNIT_ParamPassing_TEST PRIVATE - ${TinyXML2_LIBRARIES}) + target_link_libraries(UNIT_ParamPassing_TEST ${TINYXML2_LIBRARIES}) endif() endif() -sdf_add_library(${sdf_target} ${sources}) -target_compile_features(${sdf_target} PUBLIC cxx_std_17) -target_link_libraries(${sdf_target} +ign_create_core_library(SOURCES ${sources} CXX_STANDARD 17) + +target_include_directories(${PROJECT_LIBRARY_TARGET_NAME} + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} +) + +target_link_libraries(${PROJECT_LIBRARY_TARGET_NAME} PUBLIC ignition-math${IGN_MATH_VER}::ignition-math${IGN_MATH_VER} ignition-utils${IGN_UTILS_VER}::ignition-utils${IGN_UTILS_VER} PRIVATE - ${TinyXML2_LIBRARIES}) + ${TINYXML2_LIBRARIES} +) + +if (USE_INTERNAL_URDF) + target_include_directories(${PROJECT_LIBRARY_TARGET_NAME} + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/urdf + ) +else() + target_link_libraries(${PROJECT_LIBRARY_TARGET_NAME} + PRIVATE + IgnURDFDOM::IgnURDFDOM + ) +endif() if (WIN32) - target_compile_definitions(${sdf_target} PRIVATE URDFDOM_STATIC) + target_compile_definitions(${PROJECT_LIBRARY_TARGET_NAME} PRIVATE URDFDOM_STATIC) endif() -target_include_directories(${sdf_target} +target_include_directories(${PROJECT_LIBRARY_TARGET_NAME} PUBLIC $ $ ) -message (STATUS "URDF_LIBRARY_DIRS=${URDF_LIBRARY_DIRS}") -message (STATUS "URDF_LIBRARIES=${URDF_LIBRARIES}") - -if (NOT USE_INTERNAL_URDF) - target_compile_options(${sdf_target} PRIVATE ${URDF_CFLAGS}) - if (${CMAKE_VERSION} VERSION_GREATER 3.13) - target_link_options(${sdf_target} PRIVATE ${URDF_LDFLAGS}) - endif() - target_link_libraries(${sdf_target} PRIVATE ${URDF_LIBRARIES}) -endif() - -sdf_install_library(${sdf_target}) - if(NOT WIN32) add_subdirectory(cmd) endif() diff --git a/src/cmd/CMakeLists.txt b/src/cmd/CMakeLists.txt index 89534f7aa..6342379ca 100644 --- a/src/cmd/CMakeLists.txt +++ b/src/cmd/CMakeLists.txt @@ -2,15 +2,15 @@ # Generate the ruby script for internal testing. # Note that the major version of the library is included in the name. # Ex: cmdsdformat0.rb -set(cmd_script_generated_test "${CMAKE_BINARY_DIR}/test/lib/ruby/ignition/cmd${sdf_target}.rb") +set(cmd_script_generated_test "${CMAKE_BINARY_DIR}/test/lib/ruby/ignition/cmd${PROJECT_NAME}.rb") set(cmd_script_configured_test "${cmd_script_generated_test}.configured") # Set the library_location variable to the full path of the library file within # the build directory. -set(library_location "$") +set(library_location "$") configure_file( - "cmd${PROJECT_NAME_NO_VERSION_LOWER}.rb.in" + "${CMAKE_SOURCE_DIR}/src/cmd/cmd${PROJECT_NAME_NO_VERSION_LOWER}.rb.in" "${cmd_script_configured_test}" @ONLY) @@ -24,12 +24,12 @@ file(GENERATE # Generate the ruby script that gets installed. # Note that the major version of the library is included in the name. # Ex: cmdsdformat0.rb -set(cmd_script_generated "${CMAKE_CURRENT_BINARY_DIR}/cmd${sdf_target}.rb") +set(cmd_script_generated "${CMAKE_CURRENT_BINARY_DIR}/cmd${PROJECT_NAME}.rb") set(cmd_script_configured "${cmd_script_generated}.configured") # Set the library_location variable to the relative path to the library file # within the install directory structure. -set(library_location "../../../${CMAKE_INSTALL_LIBDIR}/$") +set(library_location "../../../${CMAKE_INSTALL_LIBDIR}/$") configure_file( "cmd${PROJECT_NAME_NO_VERSION_LOWER}.rb.in" diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 22926fd5a..58ddad3d7 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,33 +1,17 @@ -include_directories ( - ${PROJECT_SOURCE_DIR}/include - ${PROJECT_BINARY_DIR}/include - ${PROJECT_SOURCE_DIR}/test/gtest/include - ${PROJECT_SOURCE_DIR}/test/gtest - ${PROJECT_SOURCE_DIR}/test - ${IGNITION-MATH_INCLUDE_DIRS} -) - -link_directories( - ${IGNITION-MATH_LIBRARY_DIRS} -) - -if (USE_EXTERNAL_TINYXML) - include_directories(${tinyxml_INCLUDE_DIRS}) - link_directories(${tinyxml_LIBRARY_DIRS}) -endif() - configure_file(test_config.h.in ${PROJECT_BINARY_DIR}/test_config.h) # Build gtest add_library(gtest STATIC gtest/src/gtest-all.cc) +target_include_directories(gtest + PRIVATE + ${PROJECT_SOURCE_DIR}/test/gtest/include + ${PROJECT_SOURCE_DIR}/test/gtest +) add_library(gtest_main STATIC gtest/src/gtest_main.cc) target_link_libraries(gtest_main gtest) -set(GTEST_LIBRARY "${PROJECT_BINARY_DIR}/test/libgtest.a") -set(GTEST_MAIN_LIBRARY "${PROJECT_BINARY_DIR}/test/libgtest_main.a") execute_process(COMMAND cmake -E remove_directory ${CMAKE_BINARY_DIR}/test_results) execute_process(COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/test_results) -include_directories(${GTEST_INCLUDE_DIRS}) add_subdirectory(integration) add_subdirectory(performance) diff --git a/test/integration/CMakeLists.txt b/test/integration/CMakeLists.txt index ddfb34936..ea0bdc043 100644 --- a/test/integration/CMakeLists.txt +++ b/test/integration/CMakeLists.txt @@ -8,6 +8,7 @@ set(tests collision_dom.cc converter.cc default_elements.cc + deprecated_headers.cc deprecated_specs.cc disable_fixed_joint_reduction.cc element_tracing.cc @@ -62,12 +63,10 @@ find_program(XMLLINT_EXE xmllint) if (EXISTS ${XMLLINT_EXE}) set (tests ${tests} schema_test.cc) else() - BUILD_WARNING("xmllint not found. schema_test won't be run") + ign_build_warning("xmllint not found. schema_test won't be run") endif() -link_directories(${PROJECT_BINARY_DIR}/test) - -sdf_build_tests(${tests}) +ign_build_tests(TYPE ${TEST_TYPE} SOURCES ${tests} INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/test) if (EXISTS ${XMLLINT_EXE}) # Need to run schema target (build .xsd files) before running schema_test @@ -78,5 +77,5 @@ endif() if (UNIX AND NOT APPLE) configure_file(all_symbols_have_version.bash.in ${CMAKE_CURRENT_BINARY_DIR}/all_symbols_have_version.bash @ONLY) add_test(NAME INTEGRATION_versioned_symbols - COMMAND bash ${CMAKE_CURRENT_BINARY_DIR}/all_symbols_have_version.bash ${CMAKE_BINARY_DIR}/src/libsdformat${SDF_MAJOR_VERSION}.so) + COMMAND bash ${CMAKE_CURRENT_BINARY_DIR}/all_symbols_have_version.bash ${CMAKE_BINARY_DIR}/src/libsdformat${PROJECT_VERSION_MAJOR}.so) endif() diff --git a/test/integration/deprecated_headers.cc b/test/integration/deprecated_headers.cc new file mode 100644 index 000000000..17898a12e --- /dev/null +++ b/test/integration/deprecated_headers.cc @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2021 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. + * + */ + +/** + * This simply tests if it builds with the deprecated headers. The downside of this + * is that it taints the build output with false positive warnings. + */ +#include +#include + +int main() +{ + return 0; +} diff --git a/test/performance/CMakeLists.txt b/test/performance/CMakeLists.txt index 8df89ac74..807cb38e6 100644 --- a/test/performance/CMakeLists.txt +++ b/test/performance/CMakeLists.txt @@ -4,6 +4,4 @@ set(tests parser_urdf.cc ) -link_directories(${PROJECT_BINARY_DIR}/test) - -sdf_build_tests(${tests}) +ign_build_tests(TYPE ${TEST_TYPE} SOURCES ${tests} INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/test)