From 718f0c0807d49c4effb96946793ffe81ce43fb11 Mon Sep 17 00:00:00 2001 From: VictorLee Date: Fri, 13 Aug 2021 17:24:55 +0800 Subject: [PATCH] fix compile issue. --- cupoch_conversions/CMakeLists.txt | 9 +- .../cmake/CudaComputeTargetFlags.cmake | 43 +++ cupoch_conversions/cmake/FindGFlags.cmake | 50 +++ cupoch_conversions/cmake/FindTensorRT.cmake | 72 ++++ cupoch_conversions/cmake/Findthrust.cmake | 40 ++ .../cmake/GACompilerFlags.cmake | 49 +++ cupoch_conversions/cmake/GATest.cmake | 201 ++++++++++ cupoch_conversions/cmake/GAUtils.cmake | 90 +++++ .../cmake/ga_build_common.cmake | 346 ++++++++++++++++++ cupoch_conversions/package.xml | 1 - 10 files changed, 897 insertions(+), 4 deletions(-) create mode 100644 cupoch_conversions/cmake/CudaComputeTargetFlags.cmake create mode 100644 cupoch_conversions/cmake/FindGFlags.cmake create mode 100644 cupoch_conversions/cmake/FindTensorRT.cmake create mode 100644 cupoch_conversions/cmake/Findthrust.cmake create mode 100644 cupoch_conversions/cmake/GACompilerFlags.cmake create mode 100644 cupoch_conversions/cmake/GATest.cmake create mode 100644 cupoch_conversions/cmake/GAUtils.cmake create mode 100644 cupoch_conversions/cmake/ga_build_common.cmake diff --git a/cupoch_conversions/CMakeLists.txt b/cupoch_conversions/CMakeLists.txt index 629e561..cdcc2fe 100644 --- a/cupoch_conversions/CMakeLists.txt +++ b/cupoch_conversions/CMakeLists.txt @@ -1,7 +1,11 @@ cmake_minimum_required(VERSION 3.5.0) project(cupoch_conversions) -find_package(gpuac_base REQUIRED) +# Add this repository's cmake modules to CMAKE_MODULE_PATH +list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_LIST_DIR}/cmake) + +include(ga_build_common) + find_package(ament_cmake REQUIRED) find_package(ament_cmake_ros REQUIRED) @@ -38,7 +42,6 @@ cuda_add_library(cupoch_conversions STATIC src/cupoch_conversions.cu) ament_target_dependencies(cupoch_conversions rclcpp sensor_msgs - gpuac_base urdfdom ) target_include_directories(cupoch_conversions PRIVATE @@ -74,4 +77,4 @@ ament_export_libraries(cupoch_conversions) # ament_export_interfaces(export_${PROJECT_NAME}) ament_export_dependencies(rclcpp) -ament_package() \ No newline at end of file +ament_package() diff --git a/cupoch_conversions/cmake/CudaComputeTargetFlags.cmake b/cupoch_conversions/cmake/CudaComputeTargetFlags.cmake new file mode 100644 index 0000000..f24731d --- /dev/null +++ b/cupoch_conversions/cmake/CudaComputeTargetFlags.cmake @@ -0,0 +1,43 @@ +# +# Compute target flags macros by Anatoly Baksheev +# +# Usage in CmakeLists.txt: +# include(CudaComputeTargetFlags.cmake) +# APPEND_TARGET_ARCH_FLAGS() + +#compute flags macros +MACRO(CUDA_COMPUTE_TARGET_FLAGS arch_bin arch_ptx cuda_nvcc_target_flags) + string(REGEX REPLACE "\\." "" ARCH_BIN_WITHOUT_DOTS "${${arch_bin}}") + string(REGEX REPLACE "\\." "" ARCH_PTX_WITHOUT_DOTS "${${arch_ptx}}") + + set(cuda_computer_target_flags_temp "") + + # Tell NVCC to add binaries for the specified GPUs + string(REGEX MATCHALL "[0-9()]+" ARCH_LIST "${ARCH_BIN_WITHOUT_DOTS}") + foreach(ARCH IN LISTS ARCH_LIST) + if (ARCH MATCHES "([0-9]+)\\(([0-9]+)\\)") + # User explicitly specified PTX for the concrete BIN + set(cuda_computer_target_flags_temp ${cuda_computer_target_flags_temp} -gencode arch=compute_${CMAKE_MATCH_2},code=sm_${CMAKE_MATCH_1}) + else() + # User didn't explicitly specify PTX for the concrete BIN, we assume PTX=BIN + set(cuda_computer_target_flags_temp ${cuda_computer_target_flags_temp} -gencode arch=compute_${ARCH},code=sm_${ARCH}) + endif() + endforeach() + + # Tell NVCC to add PTX intermediate code for the specified architectures + string(REGEX MATCHALL "[0-9]+" ARCH_LIST "${ARCH_PTX_WITHOUT_DOTS}") + foreach(ARCH IN LISTS ARCH_LIST) + set(cuda_computer_target_flags_temp ${cuda_computer_target_flags_temp} -gencode arch=compute_${ARCH},code=compute_${ARCH}) + endforeach() + + set(${cuda_nvcc_target_flags} ${cuda_computer_target_flags_temp}) +ENDMACRO() + +MACRO(APPEND_TARGET_ARCH_FLAGS) + set(cuda_nvcc_target_flags "") + CUDA_COMPUTE_TARGET_FLAGS(CUDA_ARCH_BIN CUDA_ARCH_PTX cuda_nvcc_target_flags) + if (cuda_nvcc_target_flags) + message(STATUS "CUDA NVCC target flags: ${cuda_nvcc_target_flags}") + list(APPEND CUDA_NVCC_FLAGS ${cuda_nvcc_target_flags}) + endif() +ENDMACRO() \ No newline at end of file diff --git a/cupoch_conversions/cmake/FindGFlags.cmake b/cupoch_conversions/cmake/FindGFlags.cmake new file mode 100644 index 0000000..de6c3b1 --- /dev/null +++ b/cupoch_conversions/cmake/FindGFlags.cmake @@ -0,0 +1,50 @@ +# - Try to find GFLAGS +# +# The following variables are optionally searched for defaults +# GFLAGS_ROOT_DIR: Base directory where all GFLAGS components are found +# +# The following are set after configuration is done: +# GFLAGS_FOUND +# GFLAGS_INCLUDE_DIRS +# GFLAGS_LIBRARIES +# GFLAGS_LIBRARYRARY_DIRS + +include(FindPackageHandleStandardArgs) + +set(GFLAGS_ROOT_DIR "" CACHE PATH "Folder contains Gflags") + +# We are testing only a couple of files in the include directories +if(WIN32) + find_path(GFLAGS_INCLUDE_DIR gflags/gflags.h + PATHS ${GFLAGS_ROOT_DIR}/src/windows) +else() + find_path(GFLAGS_INCLUDE_DIR gflags/gflags.h + PATHS ${GFLAGS_ROOT_DIR}) +endif() + +if(MSVC) + find_library(GFLAGS_LIBRARY_RELEASE + NAMES libgflags + PATHS ${GFLAGS_ROOT_DIR} + PATH_SUFFIXES Release) + + find_library(GFLAGS_LIBRARY_DEBUG + NAMES libgflags-debug + PATHS ${GFLAGS_ROOT_DIR} + PATH_SUFFIXES Debug) + + set(GFLAGS_LIBRARY optimized ${GFLAGS_LIBRARY_RELEASE} debug ${GFLAGS_LIBRARY_DEBUG}) +else() + find_library(GFLAGS_LIBRARY gflags) +endif() + +find_package_handle_standard_args(GFlags DEFAULT_MSG GFLAGS_INCLUDE_DIR GFLAGS_LIBRARY) + + +if(GFLAGS_FOUND) + set(GFLAGS_INCLUDE_DIRS ${GFLAGS_INCLUDE_DIR}) + set(GFLAGS_LIBRARIES ${GFLAGS_LIBRARY}) + message(STATUS "Found gflags (include: ${GFLAGS_INCLUDE_DIR}, library: ${GFLAGS_LIBRARY})") + mark_as_advanced(GFLAGS_LIBRARY_DEBUG GFLAGS_LIBRARY_RELEASE + GFLAGS_LIBRARY GFLAGS_INCLUDE_DIR GFLAGS_ROOT_DIR) +endif() diff --git a/cupoch_conversions/cmake/FindTensorRT.cmake b/cupoch_conversions/cmake/FindTensorRT.cmake new file mode 100644 index 0000000..22c55cd --- /dev/null +++ b/cupoch_conversions/cmake/FindTensorRT.cmake @@ -0,0 +1,72 @@ +# This module defines the following variables: +# +# :: +# +# TensorRT_INCLUDE_DIRS +# TensorRT_LIBRARIES +# TensorRT_FOUND +# +# :: +# +# TensorRT_VERSION_STRING - version (x.y.z) +# TensorRT_VERSION_MAJOR - major version (x) +# TensorRT_VERSION_MINOR - minor version (y) +# TensorRT_VERSION_PATCH - patch version (z) +# +# Hints +# ^^^^^ +# A user may set ``TensorRT_ROOT`` to an installation root to tell this module where to look. +# +set(_TensorRT_SEARCHES) + +if(TensorRT_ROOT) + set(_TensorRT_SEARCH_ROOT PATHS ${TensorRT_ROOT} NO_DEFAULT_PATH) + list(APPEND _TensorRT_SEARCHES _TensorRT_SEARCH_ROOT) +endif() + +# appends some common paths +set(_TensorRT_SEARCH_NORMAL + PATHS "/usr" +) +list(APPEND _TensorRT_SEARCHES _TensorRT_SEARCH_NORMAL) + +# Include dir +foreach(search ${_TensorRT_SEARCHES}) + find_path(TensorRT_INCLUDE_DIR NAMES NvInfer.h ${${search}} PATH_SUFFIXES include) +endforeach() + +if(NOT TensorRT_LIBRARY) + foreach(search ${_TensorRT_SEARCHES}) + find_library(TensorRT_LIBRARY NAMES nvinfer ${${search}} PATH_SUFFIXES lib) + endforeach() +endif() + +mark_as_advanced(TensorRT_INCLUDE_DIR) + +if(TensorRT_INCLUDE_DIR AND EXISTS "${TensorRT_INCLUDE_DIR}/NvInfer.h") + file(STRINGS "${TensorRT_INCLUDE_DIR}/NvInfer.h" TensorRT_MAJOR REGEX "^#define NV_TENSORRT_MAJOR [0-9]+.*$") + file(STRINGS "${TensorRT_INCLUDE_DIR}/NvInfer.h" TensorRT_MINOR REGEX "^#define NV_TENSORRT_MINOR [0-9]+.*$") + file(STRINGS "${TensorRT_INCLUDE_DIR}/NvInfer.h" TensorRT_PATCH REGEX "^#define NV_TENSORRT_PATCH [0-9]+.*$") + + string(REGEX REPLACE "^#define NV_TENSORRT_MAJOR ([0-9]+).*$" "\\1" TensorRT_VERSION_MAJOR "${TensorRT_MAJOR}") + string(REGEX REPLACE "^#define NV_TENSORRT_MINOR ([0-9]+).*$" "\\1" TensorRT_VERSION_MINOR "${TensorRT_MINOR}") + string(REGEX REPLACE "^#define NV_TENSORRT_PATCH ([0-9]+).*$" "\\1" TensorRT_VERSION_PATCH "${TensorRT_PATCH}") + set(TensorRT_VERSION_STRING "${TensorRT_VERSION_MAJOR}.${TensorRT_VERSION_MINOR}.${TensorRT_VERSION_PATCH}") +endif() + +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(TensorRT REQUIRED_VARS TensorRT_LIBRARY TensorRT_INCLUDE_DIR VERSION_VAR TensorRT_VERSION_STRING) + +if(TensorRT_FOUND) + set(TensorRT_INCLUDE_DIRS ${TensorRT_INCLUDE_DIR}) + + if(NOT TensorRT_LIBRARIES) + set(TensorRT_LIBRARIES ${TensorRT_LIBRARY}) + endif() + + if(NOT TARGET TensorRT::TensorRT) + add_library(TensorRT::TensorRT UNKNOWN IMPORTED) + set_target_properties(TensorRT::TensorRT PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${TensorRT_INCLUDE_DIRS}") + set_property(TARGET TensorRT::TensorRT APPEND PROPERTY IMPORTED_LOCATION "${TensorRT_LIBRARY}") + endif() +endif() \ No newline at end of file diff --git a/cupoch_conversions/cmake/Findthrust.cmake b/cupoch_conversions/cmake/Findthrust.cmake new file mode 100644 index 0000000..7238bb3 --- /dev/null +++ b/cupoch_conversions/cmake/Findthrust.cmake @@ -0,0 +1,40 @@ + +find_path(THRUST_INCLUDE_DIR + HINTS + "/usr/include" + "/usr/local/include" + "/usr/local/cuda/include" + NAMES + "thrust/version.h") + +if(THRUST_INCLUDE_DIR) + file(STRINGS "${THRUST_INCLUDE_DIR}/thrust/version.h" + THRUST_VERSION_STRING + REGEX "#define THRUST_VERSION[ \t]+([0-9x]+)") + + string(REGEX REPLACE "#define THRUST_VERSION[ \t]+" "" THRUST_VERSION_STRING ${THRUST_VERSION_STRING}) + + math(EXPR THRUST_VERSION_MAJOR "${THRUST_VERSION_STRING} / 100000") + math(EXPR THRUST_VERSION_MINOR "(${THRUST_VERSION_STRING} / 100) % 1000") + math(EXPR THRUST_VERSION_PATCH "${THRUST_VERSION_STRING} % 100") + unset(THRUST_VERSION_STRING) + + set(THRUST_VERSION "${THRUST_VERSION_MAJOR}.${THRUST_VERSION_MINOR}.${THRUST_VERSION_PATCH}") +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(thrust + REQUIRED_VARS THRUST_INCLUDE_DIR + VERSION_VAR THRUST_VERSION) + + +if(thrust_FOUND) + add_library(thrust::thrust INTERFACE IMPORTED) + set_target_properties(thrust::thrust PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${THRUST_INCLUDE_DIR}") + + mark_as_advanced(THRUST_INCLUDE_DIR + THRUST_VERSION + THRUST_VERSION_MAJOR + THRUST_VERSION_MINOR + THRUST_VERSION_PATCH) +endif() diff --git a/cupoch_conversions/cmake/GACompilerFlags.cmake b/cupoch_conversions/cmake/GACompilerFlags.cmake new file mode 100644 index 0000000..d0986bb --- /dev/null +++ b/cupoch_conversions/cmake/GACompilerFlags.cmake @@ -0,0 +1,49 @@ +if (NOT ("${CMAKE_C_COMPILER_ID}" STREQUAL "${CMAKE_CXX_COMPILER_ID}")) + message(FATAL_ERROR "C compiler (${CMAKE_C_COMPILER_ID}) does not match C++ compiler (${CMAKE_CXX_COMPILER_ID})") +endif() + +if ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") + set(CLANG_ALL_WARNINGS "-Weverything") + list(APPEND CLANG_ALL_WARNINGS "-Wno-missing-field-initializers") # Allow c structs without all fields initialized + list(APPEND CLANG_ALL_WARNINGS "-Wno-reserved-id-macro") # Needed for azure-c-shared-utility which defines new macros that start with "_" + list(APPEND CLANG_ALL_WARNINGS "-Wno-gnu-zero-variadic-macro-arguments") # Needed too allow variadic macros with zero args + list(APPEND CLANG_ALL_WARNINGS "-Wno-extra-semi") # Allow for multiple semi-colons in a row + list(APPEND CLANG_ALL_WARNINGS "-Wno-c++98-compat-pedantic") # Allow commas on the last enum value + list(APPEND CLANG_ALL_WARNINGS "-Wno-padded") # Do not warn about inserted padding to structs + list(APPEND CLANG_ALL_WARNINGS "-Wno-switch-enum") # Do not warn about missing case statements in enums + list(APPEND CLANG_ALL_WARNINGS "-Wno-old-style-cast") # Allow old style c casts + list(APPEND CLANG_ALL_WARNINGS "-Wno-global-constructors") # Allow global constructors. Needed for gtest + list(APPEND CLANG_ALL_WARNINGS "-Wno-newline-eof") # Allow no newline at eof. Needed for azure-c-utility + list(APPEND CLANG_ALL_WARNINGS "-Wno-exit-time-destructors") # Allow exit time destructors. Needed for spdlog + list(APPEND CLANG_ALL_WARNINGS "-Wno-weak-vtables") # Allow weak vtables. Needed for spdlog + list(APPEND CLANG_ALL_WARNINGS "-Wno-undef") # Allow undefined macros. Needed for azure-c-shared-utility + list(APPEND CLANG_ALL_WARNINGS "-Wno-disabled-macro-expansion") # Allow recursive macro expansion + list(APPEND CLANG_ALL_WARNINGS "-Wno-documentation-unknown-command") # Allow undocumented documentation commands used by doxygen + list(APPEND CLANG_ALL_WARNINGS "-Wno-covered-switch-default") # Allow default: in switch statements that cover all enum values + list(APPEND CLANG_ALL_WARNINGS "-Wno-unreachable-code-break") # Allow break even if it is unreachable + list(APPEND CLANG_ALL_WARNINGS "-Wno-double-promotion") # Allow floats to be promoted to doubles. Needed for isnan() on some systems + if (NOT (${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS "5.0.0")) + # Added in clang 5 + list(APPEND CLANG_ALL_WARNINGS "-Wno-zero-as-null-pointer-constant") # Allow zero as nullptr + endif() + set(CLANG_WARNINGS_AS_ERRORS "-Werror") + add_compile_options(${CLANG_ALL_WARNINGS}) + # zs: 太严格了 + # add_compile_options(${CLANG_WARNINGS_AS_ERRORS}) +elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") + set(GNU_ALL_WARNINGS "-Wall" "-Wextra") + list(APPEND GNU_ALL_WARNINGS "-Wno-missing-field-initializers") # Allow c structs without all fields initialized + set(GNU_WARNINGS_AS_ERRORS "-Werror") + add_compile_options(${GNU_ALL_WARNINGS}) + # zs: 太严格了 + # add_compile_options(${GNU_WARNINGS_AS_ERRORS}) +elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") + set(MSVC_ALL_WARNINGS "/W4" "/wd4200") #Note: allow zero length arrays + set(MSVC_WARNINGS_AS_ERRORS "/WX") + string(REGEX REPLACE " /W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + string(REGEX REPLACE " /W[0-4]" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") + add_compile_options(${MSVC_ALL_WARNINGS}) + add_compile_options(${MSVC_WARNINGS_AS_ERRORS}) +else() + message(FATAL_ERROR "Unknown C++ compiler: ${CMAKE_CXX_COMPILER_ID}") +endif() diff --git a/cupoch_conversions/cmake/GATest.cmake b/cupoch_conversions/cmake/GATest.cmake new file mode 100644 index 0000000..b632e5f --- /dev/null +++ b/cupoch_conversions/cmake/GATest.cmake @@ -0,0 +1,201 @@ +# Add a test +# +# ga_add_tests(TARGET +# TEST_TYPE +# WORKING_DIRECTORY +# [HARDWARE_REQUIRED]) +# +# TARGET - Name of build target that is the test binary +# +# TEST_TYPE - The type of test this build target is running. +# UNIT - Tests meant to run on build machine. These tests run very +# quickly (<1s), and reproducible, and do not require +# hardware. +# +# FUNCTIONAL - Tests meant to run on test machine. These tests run +# quickly (<10s), may require hardware, run on PCs that +# meet min spec requirements, and are reproducible. +# +# STRESS - Tests that run repeatedly and look for statistical +# failures +# +# PERF - Tests that run on target environment and report perf stats. +# These tests are not pass fail +# +# WORKING_DIRECTORY - Working directory to run the UnitTest +# +# Adds a googletest framework test to the OD test list +# +# Results of the test will be output in XML form and consumed by the CI system +# + +set(GTest_ROOT /usr/src/googletest/googletest) +if (NOT TARGET gtest) + set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) + option(INSTALL_GTEST "" OFF) + option(INSTALL_GMOCK "" OFF) + add_subdirectory(${GTest_ROOT} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/googletest EXCLUDE_FROM_ALL) +else() + message(STATUS "gtest is already a target. Skipping adding it twice") +endif() +add_library(gtest::gtest ALIAS gtest) + +include(GoogleTest) + +get_property(is_defined GLOBAL PROPERTY TEST_TYPES DEFINED) +if (NOT is_defined) + define_property(GLOBAL PROPERTY TEST_TYPES + BRIEF_DOCS "List of types of tests" + FULL_DOCS "Contains full list of all test types") + + set(TEST_TYPES "UNIT" "FUNCTIONAL" "STRESS" "PERF" "FIRMWARE") + set_property(GLOBAL PROPERTY TEST_TYPES ${TEST_TYPES}) + + foreach(TEST_TYPE ${TEST_TYPES}) + if ("${CMAKE_CONFIGURATION_TYPES}" STREQUAL "") + get_property(is_defined GLOBAL PROPERTY ${TEST_TYPE}_TEST_LIST DEFINED) + if(is_defined) + message(FATAL_ERROR "${${TEST_TYPE}_TEST_LIST} is already defined.") + endif() + define_property(GLOBAL PROPERTY ${TEST_TYPE}_TEST_LIST + BRIEF_DOCS "List of ${TEST_TYPE} tests" + FULL_DOCS "Contains full list of tests of type ${TEST_TYPE}") + else() + foreach(CONFIG ${CMAKE_CONFIGURATION_TYPES}) + get_property(is_defined GLOBAL PROPERTY ${CONFIG}_${TEST_TYPE}_TEST_LIST DEFINED) + if(is_defined) + message(FATAL_ERROR "${${CONFIG}_${TEST_TYPE}_TEST_LIST} is already defined.") + endif() + define_property(GLOBAL PROPERTY ${CONFIG}_${TEST_TYPE}_TEST_LIST + BRIEF_DOCS "List of ${CONFIG} ${TEST_TYPE} tests" + FULL_DOCS "Contains full list of tests of type ${TEST_TYPE} for ${CONFIG} builds") + endforeach() + endif() + endforeach() + + unset(TEST_TYPES) +endif() + +# string(JOIN ...) was added in CMake 3.11 and thus can not be used. +# string_join was written to mimic string(JOIN ...) functionality and +# interface. +function(string_join GLUE OUTPUT VALUES) + set(_TEMP_VALUES ${VALUES} ${ARGN}) + string(REPLACE ";" "${GLUE}" _TEMP_STR "${_TEMP_VALUES}") + set(${OUTPUT} "${_TEMP_STR}" PARENT_SCOPE) +endfunction() + +function(ga_add_tests) + cmake_parse_arguments( + GA_ADD_TESTS # Prefix + "HARDWARE_REQUIRED" # Options + "TARGET;TEST_TYPE;WORKING_DIRECTORY" # One value keywords + "" # Multi value keywords + ${ARGN}) # args... + + if (NOT GA_ADD_TESTS_TARGET) + message(FATAL_ERROR "No TARGET supplied to ga_add_tests") + endif() + + if (NOT GA_ADD_TESTS_TEST_TYPE) + message(FATAL_ERROR "No TEST_TYPE supplied to ga_add_tests") + endif() + + if (NOT GA_ADD_TESTS_WORKING_DIRECTORY) + set(GA_ADD_TESTS_WORKING_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}") + endif() + + get_property(TEST_TYPES GLOBAL PROPERTY TEST_TYPES) + + if (NOT ${GA_ADD_TESTS_TEST_TYPE} IN_LIST TEST_TYPES) + string_join(" " TEST_TYPES_STR ${TEST_TYPES}) + message( + FATAL_ERROR + "Unknown TEST_TYPE ${GA_ADD_TESTS_TEST_TYPE} for target \ + ${GA_ADD_TESTS_TARGET}. Valid options are: ${TEST_TYPES_STR}") + endif() + + string(TOLOWER ${GA_ADD_TESTS_TEST_TYPE} TEST_TYPE) + set(HARDWARE_REQUIRED ${GA_ADD_TESTS_HARDWARE_REQUIRED}) + + if ((${TEST_TYPE} STREQUAL "unit") AND (${HARDWARE_REQUIRED})) + message(FATAL_ERROR "OD test (${GA_ADD_TESTS_TARGET}) may not + be both the UNIT test type and require hardware") + endif() + + set(LABELS "") + + if (${HARDWARE_REQUIRED}) + list(APPEND LABELS "hardware") + endif() + + list(APPEND LABELS ${TEST_TYPE}) + + # This is a work around to issue 17812 with cmake. In order to set + # multiple labels on a test, we need to pass in "LABELS" in front of each + # label. For example, if we have the labels "hardware" and "functional" we + # should pass in "LABELS;hardware;LABELS;functional" to cmake. + # See issue here: https://gitlab.kitware.com/cmake/cmake/issues/17812 + set(GTEST_PROPERTIES) + foreach(LABEL ${LABELS}) + list(APPEND GTEST_PROPERTIES "LABELS;${LABEL}") + endforeach() + + # Turn on logging to stdout + if (NOT DEFINED ENV{GA_LOG_LEVEL}) + list(APPEND GTEST_PROPERTIES "ENVIRONMENT;GA_LOG_LEVEL=I;") + endif() + + if (NOT DEFINED ENV{GA_ENABLE_LOG_TO_STDOUT}) + list(APPEND GTEST_PROPERTIES "ENVIRONMENT;GA_ENABLE_LOG_TO_STDOUT=1") + endif() + + + set(TIMEOUT_VAR_NAME "DISCOVERY_TIMEOUT") + if ((${CMAKE_VERSION} VERSION_EQUAL "3.10.1") OR (${CMAKE_VERSION} VERSION_EQUAL "3.10.2")) + set(TIMEOUT_VAR_NAME "TIMEOUT") + endif() + + gtest_discover_tests( + ${GA_ADD_TESTS_TARGET} + EXTRA_ARGS + "--gtest_output=xml:TEST-${GA_ADD_TESTS_TARGET}.xml" + WORKING_DIRECTORY + ${GA_ADD_TESTS_WORKING_DIRECTORY} + ${TIMEOUT_VAR_NAME} + 60 + PROPERTIES + "${GTEST_PROPERTIES}") + + if ("${CMAKE_CONFIGURATION_TYPES}" STREQUAL "") + set_property( + GLOBAL + APPEND + PROPERTY ${TEST_TYPE}_TEST_LIST + ${GA_ADD_TESTS_TARGET}${CMAKE_EXECUTABLE_SUFFIX}) + + get_property(TESTS GLOBAL PROPERTY ${TEST_TYPE}_TEST_LIST) + + string_join("\n" TESTS_STR ${TESTS}) + file( + WRITE + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TEST_TYPE}_test_list.txt + ${TESTS_STR}) + else() + foreach(CONFIG ${CMAKE_CONFIGURATION_TYPES}) + set_property( + GLOBAL + APPEND + PROPERTY ${CONFIG}_${TEST_TYPE}_TEST_LIST + "${GA_ADD_TESTS_TARGET}${CMAKE_EXECUTABLE_SUFFIX}") + + get_property(TESTS GLOBAL PROPERTY ${CONFIG}_${TEST_TYPE}_TEST_LIST) + + string_join("\n" TESTS_STR ${TESTS}) + file( + WRITE + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CONFIG}/${TEST_TYPE}_test_list.txt + ${TESTS_STR}) + endforeach() + endif() +endfunction() \ No newline at end of file diff --git a/cupoch_conversions/cmake/GAUtils.cmake b/cupoch_conversions/cmake/GAUtils.cmake new file mode 100644 index 0000000..8306e4f --- /dev/null +++ b/cupoch_conversions/cmake/GAUtils.cmake @@ -0,0 +1,90 @@ +# clears all passed variables +macro(ga_clear_vars) + foreach(_var ${ARGN}) + unset(${_var} CACHE) + endforeach() +endmacro() + +# read set of version defines from the header file +macro(ga_parse_header FILENAME FILE_VAR) + set(vars_regex "") + set(__parnet_scope OFF) + set(__add_cache OFF) + foreach(name ${ARGN}) + if(${name} STREQUAL "PARENT_SCOPE") + set(__parnet_scope ON) + elseif(${name} STREQUAL "CACHE") + set(__add_cache ON) + elseif(vars_regex) + set(vars_regex "${vars_regex}|${name}") + else() + set(vars_regex "${name}") + endif() + endforeach() + if(EXISTS "${FILENAME}") + file(STRINGS "${FILENAME}" ${FILE_VAR} REGEX "#define[ \t]+(${vars_regex})[ \t]+[0-9]+" ) + else() + unset(${FILE_VAR}) + endif() + foreach(name ${ARGN}) + if(NOT ${name} STREQUAL "PARENT_SCOPE" AND NOT ${name} STREQUAL "CACHE") + if(${FILE_VAR}) + if(${FILE_VAR} MATCHES ".+[ \t]${name}[ \t]+([0-9]+).*") + string(REGEX REPLACE ".+[ \t]${name}[ \t]+([0-9]+).*" "\\1" ${name} "${${FILE_VAR}}") + else() + set(${name} "") + endif() + if(__add_cache) + set(${name} ${${name}} CACHE INTERNAL "${name} parsed from ${FILENAME}" FORCE) + elseif(__parnet_scope) + set(${name} "${${name}}" PARENT_SCOPE) + endif() + else() + unset(${name} CACHE) + endif() + endif() + endforeach() +endmacro() + +# read single version define from the header file +macro(ga_parse_header2 LIBNAME HDR_PATH VARNAME) + ga_clear_vars(${LIBNAME}_VERSION_MAJOR + ${LIBNAME}_VERSION_MAJOR + ${LIBNAME}_VERSION_MINOR + ${LIBNAME}_VERSION_PATCH + ${LIBNAME}_VERSION_TWEAK + ${LIBNAME}_VERSION_STRING) + set(${LIBNAME}_H "") + if(EXISTS "${HDR_PATH}") + file(STRINGS "${HDR_PATH}" ${LIBNAME}_H REGEX "^#define[ \t]+${VARNAME}[ \t]+\"[^\"]*\".*$" LIMIT_COUNT 1) + endif() + + if(${LIBNAME}_H) + string(REGEX REPLACE "^.*[ \t]${VARNAME}[ \t]+\"([0-9]+).*$" "\\1" ${LIBNAME}_VERSION_MAJOR "${${LIBNAME}_H}") + string(REGEX REPLACE "^.*[ \t]${VARNAME}[ \t]+\"[0-9]+\\.([0-9]+).*$" "\\1" ${LIBNAME}_VERSION_MINOR "${${LIBNAME}_H}") + string(REGEX REPLACE "^.*[ \t]${VARNAME}[ \t]+\"[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" ${LIBNAME}_VERSION_PATCH "${${LIBNAME}_H}") + set(${LIBNAME}_VERSION_MAJOR ${${LIBNAME}_VERSION_MAJOR} ${ARGN}) + set(${LIBNAME}_VERSION_MINOR ${${LIBNAME}_VERSION_MINOR} ${ARGN}) + set(${LIBNAME}_VERSION_PATCH ${${LIBNAME}_VERSION_PATCH} ${ARGN}) + set(${LIBNAME}_VERSION_STRING "${${LIBNAME}_VERSION_MAJOR}.${${LIBNAME}_VERSION_MINOR}.${${LIBNAME}_VERSION_PATCH}") + + # append a TWEAK version if it exists: + set(${LIBNAME}_VERSION_TWEAK "") + if("${${LIBNAME}_H}" MATCHES "^.*[ \t]${VARNAME}[ \t]+\"[0-9]+\\.[0-9]+\\.[0-9]+\\.([0-9]+).*$") + set(${LIBNAME}_VERSION_TWEAK "${CMAKE_MATCH_1}" ${ARGN}) + endif() + if(${LIBNAME}_VERSION_TWEAK) + set(${LIBNAME}_VERSION_STRING "${${LIBNAME}_VERSION_STRING}.${${LIBNAME}_VERSION_TWEAK}" ${ARGN}) + else() + set(${LIBNAME}_VERSION_STRING "${${LIBNAME}_VERSION_STRING}" ${ARGN}) + endif() + endif() +endmacro() + +# read single version info from the pkg file +macro(ga_get_version_from_pkg LIBNAME PKG_PATH OUTPUT_VAR) + if(EXISTS "${PKG_PATH}/${LIBNAME}.pc") + file(STRINGS "${PKG_PATH}/${LIBNAME}.pc" line_to_parse REGEX "^Version:[ \t]+[0-9.]*.*$" LIMIT_COUNT 1) + string(REGEX REPLACE ".*Version: ([^ ]+).*" "\\1" ${OUTPUT_VAR} "${line_to_parse}" ) + endif() +endmacro() diff --git a/cupoch_conversions/cmake/ga_build_common.cmake b/cupoch_conversions/cmake/ga_build_common.cmake new file mode 100644 index 0000000..0492900 --- /dev/null +++ b/cupoch_conversions/cmake/ga_build_common.cmake @@ -0,0 +1,346 @@ +# general config +set(GA_BUILD_TEST ON) + +# root dirs +set(CUPOCH_ROOT "/opt/cupoch/cupoch/") + +find_package(OpenMP) +if (OPENMP_FOUND) + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") +endif() + +# Add this repository's cmake modules to CMAKE_MODULE_PATH +list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_LIST_DIR}) +# 优先查找,增加对特定版本的支持,解注释后要清除重新编译 +# 增加对opencv4支持 +# 单独在各个项目中list, 公共部分使用opencv3 +# list(INSERT CMAKE_PREFIX_PATH 0 /opt/opencv/opencv-4.3/) +# list(INSERT CMAKE_PREFIX_PATH 0 /opt/opencv/opencv-4.2/) +# list(INSERT CMAKE_PREFIX_PATH 0 /opt/opencv/opencv-4.3.0/) +# list(INSERT CMAKE_PREFIX_PATH 0 /opt/opencv/opencv-4.2.0/) +# list(INSERT CMAKE_PREFIX_PATH 0 /opt/opencv/opencv-4.5.1/) +# 增加对libtorch的支持 +list(INSERT CMAKE_PREFIX_PATH 0 $ENV{HOME}/opt/libtorch) +# 增加对caffe的支持 +list(INSERT CMAKE_PREFIX_PATH 0 /opt/caffe/caffe-mobilenet-ssd) +# 增加对pcl的支持 +# 用默认的pcl1.8 +# list(INSERT CMAKE_PREFIX_PATH 0 /opt/pcl/pcl-1.9.1) +# list(INSERT CMAKE_PREFIX_PATH 0 /opt/pcl/pcl-1.10.1) +# 增加对open3d的支持 +list(INSERT CMAKE_PREFIX_PATH 0 /opt/open3d/open3d-gpu) +list(INSERT CMAKE_PREFIX_PATH 0 /opt/open3d/open3d) +# 使用自带eigen +list(INSERT CMAKE_PREFIX_PATH 0 /opt/eigen/eigen) +# 增加对cupoch支持 +find_package(PkgConfig QUIET) +find_package(pybind11 QUIET) +include(GenerateExportHeader) +if (PKGCONFIG_FOUND) + pkg_search_module(EIGEN3 eigen3>=3.2.7 QUIET) + pkg_search_module(GLFW glfw3 QUIET) + pkg_search_module(GLEW glew QUIET) + pkg_search_module(JSONCPP jsoncpp>=1.7.0 QUIET) + pkg_search_module(PNG libpng>=1.6.0 QUIET) + pkg_search_module(JPEG_TURBO libturbojpeg QUIET) +endif (PKGCONFIG_FOUND) +set(CUPOCH_INCLUDE_DIRS ${CUPOCH_ROOT}/include + ${CUPOCH_ROOT}/third_party + ${CUPOCH_ROOT}/third_party/rmm/include + ${CUPOCH_ROOT}/third_party/cnmem/include + ${CUPOCH_ROOT}/third_party/fmt/include + ${CUPOCH_ROOT}/third_party/liblzf/include + ${CUPOCH_ROOT}/third_party/eigen/ + ${PNG_INCLUDE_DIRS} + ${JSONCPP_INCLUDE_DIRS} +) +set(CUPOCH_LIBRARY_DIRS ${CUPOCH_ROOT}/lib) +set(CUPOCH_LIBRARIES + cupoch_camera + cupoch_collision + cupoch_geometry + cupoch_integration + cupoch_io + cupoch_odometry + cupoch_planning + cupoch_registration + cupoch_utility + cupoch_visualization + tinyobjloader + turbojpeg + stdgpu + flann_cuda_s + fmt + rmm + liblzf + rply + ${CUDA_LIBRARIES} + ${CUDA_CUBLAS_LIBRARIES} + ${CUDA_curand_LIBRARY} + ${PNG_LIBRARIES} + ${JSONCPP_LIBRARIES} +) +set(CUPOCH_NVCC_FLAGS + --expt-relaxed-constexpr + --expt-extended-lambda + --default-stream per-thread + --use_fast_math + -Xcudafe "--diag_suppress=integer_sign_change" + -Xcudafe "--diag_suppress=partial_override" + -Xcudafe "--diag_suppress=virtual_function_decl_hidden" +) +if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo" ) + list(APPEND CUPOCH_NVCC_FLAGS + -G;-g + ) +endif() +set(CUPOCH_DEFINITIONS + # -DFLANN_USE_CUDA + -DUSE_RMM +) +link_directories(${CUPOCH_LIBRARY_DIRS}) + +include(GAUtils) +include(CudaComputeTargetFlags) + +# default rel type +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + message(STATUS "Setting build type to Release as none was specified.") + set(CMAKE_BUILD_TYPE "Release" CACHE + STRING "Choose the type of build." FORCE) + # Set the possible values of build type for cmake-gui + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Release" "MinSizeRel" "RelWithDebInfo") +endif() +set(TARGET_ARCH ${CMAKE_SYSTEM_PROCESSOR}) +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_C_STANDARD 11) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +set(CMAKE_POSITION_INDEPENDENT_CODE ON) +# Clang tidy +if(TIDY_WITH_CLANG) + string(CONCAT CMAKE_CXX_CLANG_TIDY + "clang-tidy;" + "-checks=-*," + "bugprone-*," + "cert-*," + "cppcoreguidelines-*," + "clang-analyze-*," + "google-*," + "hicpp-*," + "modernize-*," + "performance-*," + "readability-*") + message(${CMAKE_CXX_CLANG_TIDY}) +endif() +# enable c++14 +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -fPIC -O3 -Wno-write-strings") +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath -Wl,$ORIGIN") +if (NOT BUILD_SHARED_LIBS) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -fvisibility-inlines-hidden") +endif (NOT BUILD_SHARED_LIBS) +add_compile_options(-Wno-deprecated-declarations) +# In Release build -O3 will be added automatically by CMake +# We still enable -O3 at debug build to optimize performance +if (uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG") + add_definitions(-O3) +endif() +# Before CMake 3.14 setting CMAKE_POSITION_INDEPENDENT_CODE did not set the +# "-pie" flag for GCC or Clang +if("${CMAKE_VERSION}" VERSION_LESS "3.14.0") + if ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie") + endif() +endif() +option(COVERAGE_ENABLED "Enable code coverage" FALSE) +if(COVERAGE_ENABLED) + add_compile_options(--coverage) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage") +endif() +# Turn on compiler flags for our code +include(GACompilerFlags) + + +# cpack +find_program(LSB_RELEASE_EXEC lsb_release) +# Ubuntu +execute_process(COMMAND ${LSB_RELEASE_EXEC} -is + OUTPUT_VARIABLE LSB_DISTRIBUTE_ID_SHORT + OUTPUT_STRIP_TRAILING_WHITESPACE +) +execute_process(COMMAND ${LSB_RELEASE_EXEC} -rs + OUTPUT_VARIABLE LSB_RELEASE_ID_SHORT + OUTPUT_STRIP_TRAILING_WHITESPACE +) +execute_process(COMMAND ${LSB_RELEASE_EXEC} -cs + OUTPUT_VARIABLE LSB_CODE_SHORT + OUTPUT_STRIP_TRAILING_WHITESPACE +) +if (${LSB_CODE_SHORT} STREQUAL "bionic") + set(GA_ROS_VERSION "dashing") +else() + set(GA_ROS_VERSION "foxy") +endif() + +set(ROS_DISTRO $ENV{ROS_DISTRO}) +if(${ROS_DISTRO} STREQUAL "dashing") + add_definitions(-DROS_DISTRO_DASHING) +elseif(${ROS_DISTRO} STREQUAL "foxy") + add_definitions(-DROS_DISTRO_FOXY) +endif() + +# Packaging support +# ament +set(CATKIN_BUILD_BINARY_PACKAGE true) +set(CMAKE_INSTALL_LIBDIR lib) +set(CMAKE_INSTALL_BINDIR lib/${PROJECT_NAME}) +set(CMAKE_INSTALL_INCLUDEDIR include/${PROJECT_NAME}) +set(CMAKE_INSTALL_SHAREDIR share/${PROJECT_NAME}) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../) +# set(CPACK_PACKAGING_INSTALL_PREFIX "/opt/ros/dashing") +# set(CPACK_SET_DESTDIR "/opt/ros/dashing/") + +set(CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS + OWNER_READ OWNER_WRITE OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE) +set(CPACK_PACKAGE_VENDOR "GATeam") +set(CPACK_PACKAGE_CONTACT "lizhensheng03") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "C/C++ SDK for GA") +set(CPACK_PACKAGE_DESCRIPTION "C/C++ SDK for GA") +set(CPACK_PACKAGE_VERSION_MAJOR ${GA_VERSION_MAJOR}) +set(CPACK_PACKAGE_VERSION_MINOR ${GA_VERSION_MINOR}) +set(CPACK_PACKAGE_VERSION_PATCH ${GA_VERSION_PATCH}) +# set(CPACK_PACKAGE_VERSION ${GA_VERSION_STR}) +# set(CPACK_PACKAGE_VERSION ${TODAY}-${GA_COMMIT_ID}-${LSB_RELEASE_ID_SHORT}-${TARGET_ARCH}-${CMAKE_BUILD_TYPE}) +set(CPACK_PACKAGE_VERSION ${TODAY}-${GA_COMMIT_ID}) +set(CPACK_PACKAGE_NAME "ros-${GA_ROS_VERSION}-${PROJECT_NAME}") +# set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${GA_COMMIT_ID}.${LSB_DISTRIBUTE_ID_SHORT}.${LSB_RELEASE_ID_SHORT}.${TARGET_ARCH}.${CMAKE_BUILD_TYPE}") +set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${TODAY}-${GA_COMMIT_ID}-CUDA${CUDA_VERSION}-${LSB_RELEASE_ID_SHORT}.${TARGET_ARCH}.${CMAKE_BUILD_TYPE}") +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") +set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md") +set(CPACK_COMPONENTS_GROUPING "ONE_PER_GROUP") +set(CPACK_GENERATOR "DEB") +set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}) +# include(CPack) +# cpack_add_component( +# runtime +# DISPLAY_NAME +# Runtime +# DESCRIPTION +# "Dynamic Libraries for GA Runtime" +# REQUIRED +# ) +# cpack_add_component( +# development +# DISPLAY_NAME +# Development +# DESCRIPTION +# "Headers and cmake files needed for GA Development" +# REQUIRED +# DEPENDS +# runtime +# ) +# cpack_add_component( +# tools +# DISPLAY_NAME +# Tools +# DESCRIPTION +# "Tools for GA Development" +# REQUIRED +# DEPENDS +# runtime +# ) + +message(STATUS "CUDA compilation status: $ENV{GPUAC_COMPILE_WITH_CUDA}.") + +macro(GA_CHECK_CUDA) + if ($ENV{GPUAC_COMPILE_WITH_CUDA}) + find_package(CUDA REQUIRED QUIET) + find_package(Eigen3 REQUIRED QUIET) + + # if(NOT ${CUDA_VERSION} VERSION_LESS "10.0" + # AND NOT ${CUDA_VERSION} VERSION_EQUAL "10.0" ) + # message(FATAL_ERROR "GPU support on Melodic requires CUDA<=10.0") + # endif() + if(${CUDA_VERSION} VERSION_GREATER "9.1" + AND ${CMAKE_VERSION} VERSION_LESS "3.12.3") + unset(CUDA_cublas_device_LIBRARY CACHE) + set(CUDA_cublas_device_LIBRARY ${CUDA_cublas_LIBRARY}) + set(CUDA_CUBLAS_LIBRARIES ${CUDA_cublas_LIBRARY}) + endif() + # if ("$ENV{ROS_DISTRO}" STREQUAL "melodic" AND ${EIGEN3_VERSION_STRING} VERSION_LESS "3.3.7") + # message(FATAL_ERROR "GPU support on Melodic requires Eigen version>= 3.3.7") + # endif() + if(NOT DEFINED CMAKE_CUDA_STANDARD) + set(CMAKE_CUDA_STANDARD 14) + set(CMAKE_CUDA_STANDARD_REQUIRED ON) + endif() + set(USE_CUDA ON) + else() + message(WARNING "CUDA support is disabled. Set the GPUAC_COMPILE_WITH_CUDA environment variable and recompile to enable it") + set(USE_CUDA OFF) + endif() +endmacro() + +# Try to adhere to strict ISO C++ as much as possible: +# from https://lefticus.gitbooks.io/cpp-best-practices/content/02-Use_the_Tools_Available.html +function(autoware_set_compile_options target) +if(WIN32) + # Causes the visibility macros to use dllexport rather than dllimport, + # which is appropriate when building the dll but not consuming it. + string(TOUPPER ${target} PROJECT_NAME_UPPER) + target_compile_definitions(${target} PRIVATE ${PROJECT_NAME_UPPER}_BUILDING_DLL) + target_compile_options(${target} PRIVATE "/bigobj") + add_definitions(-D_CRT_NONSTDC_NO_WARNINGS) + add_definitions(-D_CRT_SECURE_NO_WARNINGS) + add_definitions(-D_WINSOCK_DEPRECATED_NO_WARNINGS) +else() + target_compile_options(${target} PRIVATE + -Wall + -Werror + -Wextra + #-Wshadow # causes issues with ROS 2 headers + #-Wnon-virtual-dtor # causes issues with ROS 2 headers + -pedantic + -Wcast-align + -Wunused + -Wconversion + -Wsign-conversion + -Wdouble-promotion + #-Wnull-dereference # gcc6 + #-Wduplicated-branches # gcc7 + #-Wduplicated-cond # gcc6 + #-Wrestrict # gcc7 + -fvisibility=hidden) + # C++-only options + target_compile_options(${target} + PRIVATE $<$: -Woverloaded-virtual -Wold-style-cast>) + + if(NOT APPLE) + # GCC/G++ Only, not CLang + target_compile_options(${target} + PUBLIC $<$: -Wuseless-cast>) + target_compile_options(${target} PRIVATE -Wlogical-op -frecord-gcc-switches) + endif() + + if(CMAKE_BUILD_TYPE STREQUAL "Debug") + set_target_properties(${target} PROPERTIES COMPILE_FLAGS "-Og") + else() + set_target_properties(${target} PROPERTIES COMPILE_FLAGS "-O3 -ftree-vectorize") + endif() +endif() +endfunction() + + +function(ga_install target) + install(TARGETS ${target} + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + RUNTIME DESTINATION lib/${PROJECT_NAME} + ) +endfunction() \ No newline at end of file diff --git a/cupoch_conversions/package.xml b/cupoch_conversions/package.xml index fce5593..414bf6c 100644 --- a/cupoch_conversions/package.xml +++ b/cupoch_conversions/package.xml @@ -18,7 +18,6 @@ rclcpp sensor_msgs eigen - gpuac_base urdfdom