Warning, /sdk/codevis/submodules/backward-cpp/CMakeLists.txt is written in an unsupported language. File is not indexed.

0001 #
0002 # CMakeLists.txt
0003 # Copyright 2013 Google Inc. All Rights Reserved.
0004 #
0005 # Permission is hereby granted, free of charge, to any person obtaining a copy
0006 # of this software and associated documentation files (the "Software"), to deal
0007 # in the Software without restriction, including without limitation the rights
0008 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
0009 # copies of the Software, and to permit persons to whom the Software is
0010 # furnished to do so, subject to the following conditions:
0011 #
0012 # The above copyright notice and this permission notice shall be included in
0013 # all copies or substantial portions of the Software.
0014 #
0015 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0016 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0017 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
0018 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
0019 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
0020 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
0021 # SOFTWARE.
0022 
0023 cmake_minimum_required(VERSION 3.0)
0024 project(backward CXX)
0025 
0026 # Introduce variables:
0027 # * CMAKE_INSTALL_LIBDIR
0028 # * CMAKE_INSTALL_BINDIR
0029 # * CMAKE_INSTALL_INCLUDEDIR
0030 include(GNUInstallDirs)
0031 
0032 include(BackwardConfig.cmake)
0033 
0034 # check if compiler is nvcc or nvcc_wrapper
0035 set(COMPILER_IS_NVCC false)
0036 get_filename_component(COMPILER_NAME ${CMAKE_CXX_COMPILER} NAME)
0037 if (COMPILER_NAME MATCHES "^nvcc")
0038   set(COMPILER_IS_NVCC true)
0039 endif()
0040 
0041 if (DEFINED ENV{OMPI_CXX} OR DEFINED ENV{MPICH_CXX})
0042    if ( ($ENV{OMPI_CXX} MATCHES "nvcc") OR ($ENV{MPICH_CXX} MATCHES "nvcc") )
0043      set(COMPILER_IS_NVCC true)
0044    endif()
0045 endif()
0046 
0047 # set CXX standard
0048 set(CMAKE_CXX_STANDARD_REQUIRED True)
0049 set(CMAKE_CXX_STANDARD 17)
0050 if (${COMPILER_IS_NVCC})
0051   # GNU CXX extensions are not supported by nvcc
0052   set(CMAKE_CXX_EXTENSIONS OFF)
0053 endif()
0054 
0055 ###############################################################################
0056 # COMPILER FLAGS
0057 ###############################################################################
0058 
0059 if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_COMPILER_IS_GNUCXX)
0060         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
0061         if (NOT ${COMPILER_IS_NVCC})
0062           set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic-errors")
0063         endif()
0064         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
0065 endif()
0066 
0067 ###############################################################################
0068 # BACKWARD OBJECT
0069 ###############################################################################
0070 
0071 add_library(backward_object OBJECT backward.cpp)
0072 target_compile_definitions(backward_object PRIVATE ${BACKWARD_DEFINITIONS})
0073 target_include_directories(backward_object PRIVATE ${BACKWARD_INCLUDE_DIRS})
0074 set(BACKWARD_ENABLE $<TARGET_OBJECTS:backward_object> CACHE STRING
0075         "Link with this object to setup backward automatically")
0076 
0077 
0078 ###############################################################################
0079 # BACKWARD LIBRARY (Includes backward.cpp)
0080 ###############################################################################
0081 option(BACKWARD_SHARED "Build dynamic backward-cpp shared lib" OFF)
0082 
0083 if(BACKWARD_SHARED)
0084     set(libtype SHARED)
0085 endif()
0086 add_library(backward ${libtype} backward.cpp)
0087 target_compile_definitions(backward PUBLIC ${BACKWARD_DEFINITIONS})
0088 target_include_directories(backward PUBLIC ${BACKWARD_INCLUDE_DIRS})
0089 
0090 ###############################################################################
0091 # TESTS
0092 ###############################################################################
0093 
0094 if(BACKWARD_TESTS)
0095         enable_testing()
0096 
0097         add_library(test_main OBJECT test/_test_main.cpp)
0098 
0099         macro(backward_add_test src)
0100                 get_filename_component(name ${src} NAME_WE)
0101                 set(test_name "test_${name}")
0102 
0103                 add_executable(${test_name} ${src} ${ARGN} $<TARGET_OBJECTS:test_main>)
0104 
0105                 target_link_libraries(${test_name} PRIVATE Backward::Backward)
0106 
0107                 add_test(NAME ${name} COMMAND ${test_name})
0108         endmacro()
0109 
0110         # Tests without backward.cpp
0111         set(TESTS
0112                 test
0113                 stacktrace
0114                 rectrace
0115                 select_signals
0116                 )
0117 
0118         foreach(test ${TESTS})
0119                 backward_add_test(test/${test}.cpp)
0120         endforeach()
0121 
0122         # Tests with backward.cpp
0123         set(TESTS
0124                 suicide
0125                 )
0126 
0127         foreach(test ${TESTS})
0128                 backward_add_test(test/${test}.cpp ${BACKWARD_ENABLE})
0129         endforeach()
0130 endif()
0131 
0132 install(
0133     FILES "backward.hpp"
0134     DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
0135 )
0136 install(
0137     FILES "BackwardConfig.cmake"
0138     DESTINATION ${CMAKE_INSTALL_LIBDIR}/backward
0139 )