From 72ce7c6b3d5fa21d2c1806a9ea4c999e5ce5cdfa Mon Sep 17 00:00:00 2001 From: KaiN Date: Mon, 16 Jul 2018 11:29:41 +0200 Subject: [PATCH 1/9] CMake support for MinGW toolchain tested on MinGW with GCC 7.3 & DWARF2 EH --- .gitignore | 5 ++ CMakeLists.txt | 100 ++++++++++++++++++++++++++ backtrace-supported.h.cmake | 51 +++++++++++++ cmake/libbacktraceConfig.cmake | 14 ++++ cmake/libbacktraceConfigVersion.cmake | 21 ++++++ config.h.cmake | 58 +++++++++++++++ 6 files changed, 249 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 backtrace-supported.h.cmake create mode 100644 cmake/libbacktraceConfig.cmake create mode 100644 cmake/libbacktraceConfigVersion.cmake create mode 100644 config.h.cmake diff --git a/.gitignore b/.gitignore index 86a40a0..791ab25 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,8 @@ *.lo *.a *.la + +backtrace-supported\.h + +config\.h + diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..94d0425 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,100 @@ +cmake_minimum_required(VERSION 3.5) + +project(backtrace) + +set(CMAKE_CXX_FLAGS "-DHAVE_CONFIG_H -funwind-tables -frandom-seed=mySeed -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wmissing-format-attribute -Wcast-qual -g -O2") +set(CMAKE_C_FLAGS "-DHAVE_CONFIG_H -funwind-tables -frandom-seed=mySeed -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wmissing-format-attribute -Wcast-qual -g -O2") + +file(GLOB sources + atomic.c dwarf.c fileline.c posix.c print.c sort.c state.c backtrace.c + simple.c pecoff.c read.c alloc.c config.h +) +file(GLOB export_headers + backtrace.h backtrace-supported.h +) + +add_library(${PROJECT_NAME} ${sources}) + +if(CMAKE_COMPILER_IS_GNUCC) + set(BACKTRACE_SUPPORTED 1) + + # Assume multi-threaded environment + set(BACKTRACE_SUPPORTS_THREADS 1) + + # Assume ELF/DWARF, meaning that BACKTRACE_SUPPORTS_DATA is hard-coded on. + set(BACKTRACE_SUPPORTS_DATA 1) + + find_package(ZLIB) + if(ZLIB_FOUND) + SET(HAVE_LIBZ 1) + SET(HAVE_ZLIB 1) + target_link_libraries(${PROJECT_NAME} z) + else() + SET(HAVE_LIBZ 0) + SET(HAVE_ZLIB 0) + endif() + + if(WIN32) + # Typical MinGW config + # DWARF2 exception handling could be detected based on parsing gcc --version + set(BACKTRACE_USES_MALLOC 1) + SET(BACKTRACE_ELF_SIZE unused) + SET(BACKTRACE_XCOFF_SIZE unused) + SET(HAVE_ATOMIC_FUNCTIONS 1) + SET(HAVE_CLOCK_GETTIME 1) + SET(HAVE_DECL_STRNLEN 1) + SET(HAVE_DLFCN_H 0) + SET(HAVE_DL_ITERATE_PHDR 0) + SET(HAVE_FCNTL 0) + SET(HAVE_GETEXECNAME 0) + SET(HAVE_GETIPINFO 1) + SET(HAVE_INTTYPES_H 1) + SET(HAVE_LINK_H 0) + SET(HAVE_LOADQUERY 0) + SET(HAVE_LSTAT 0) + SET(HAVE_MEMORY_H 1) + SET(HAVE_READLINK 0) + SET(HAVE_STDINT_H 1) + SET(HAVE_STDLIB_H 1) + SET(HAVE_STRINGS_H 1) + SET(HAVE_STRING_H 1) + SET(HAVE_SYNC_FUNCTIONS 1) + SET(HAVE_SYS_LDR_H 0) + SET(HAVE_SYS_MMAN_H 0) + SET(HAVE_SYS_STAT_H 1) + SET(HAVE_SYS_TYPES_H 1) + SET(HAVE_UNISTD_H 1) + else() + set(BACKTRACE_SUPPORTED 0) + endif() +else() + set(BACKTRACE_SUPPORTED 0) +endif() + +# Generate backtrace-supported.h and config.h +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/backtrace-supported.h.cmake + ${CMAKE_CURRENT_SOURCE_DIR}/backtrace-supported.h +) +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake + ${CMAKE_CURRENT_SOURCE_DIR}/config.h +) + +#install libbacktrace and header files +set(INSTALL_LIB_DIR lib/libbacktrace) +set(INSTALL_INCLUDE_DIR include/libbacktrace) +set(INSTALL_CMAKE_DIR CMake) + +# Install CMake files +install(TARGETS ${PROJECT_NAME} + DESTINATION ${INSTALL_LIB_DIR} + EXPORT lib${PROJECT_NAME}-targets +) +install(EXPORT lib${PROJECT_NAME}-targets DESTINATION ${INSTALL_CMAKE_DIR}) +install(FILES ${CMAKE_SOURCE_DIR}/cmake/lib${PROJECT_NAME}Config.cmake +${CMAKE_SOURCE_DIR}/cmake/lib${PROJECT_NAME}ConfigVersion.cmake +DESTINATION ${INSTALL_CMAKE_DIR}) + +install(TARGETS ${PROJECT_NAME} DESTINATION "${INSTALL_LIB_DIR}") +install(FILES ${export_headers} DESTINATION "${INSTALL_INCLUDE_DIR}") diff --git a/backtrace-supported.h.cmake b/backtrace-supported.h.cmake new file mode 100644 index 0000000..8e76ea0 --- /dev/null +++ b/backtrace-supported.h.cmake @@ -0,0 +1,51 @@ +/* backtrace-supported.h.cmake -- Whether stack backtrace is supported. + Copyright (C) 2012-2016 Free Software Foundation, Inc. + Based backtrace-supported.h.in, written by Ian Lance Taylor, Google. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + (1) Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + (2) 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. + (3) The name of the author may not be used to + endorse or promote products derived from this software without + specific prior written permission. +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. */ +/* The file backtrace-supported.h.in is used by configure to generate + the file backtrace-supported.h. The file backtrace-supported.h may + be #include'd to see whether the backtrace library will be able to + get a backtrace and produce symbolic information. */ +/* BACKTRACE_SUPPORTED will be #define'd as 1 if the backtrace library + should work, 0 if it will not. Libraries may #include this to make + other arrangements. */ +#cmakedefine01 BACKTRACE_SUPPORTED +/* BACKTRACE_USES_MALLOC will be #define'd as 1 if the backtrace + library will call malloc as it works, 0 if it will call mmap + instead. This may be used to determine whether it is safe to call + the backtrace functions from a signal handler. In general this + only applies to calls like backtrace and backtrace_pcinfo. It does + not apply to backtrace_simple, which never calls malloc. It does + not apply to backtrace_print, which always calls fprintf and + therefore malloc. */ +#cmakedefine01 BACKTRACE_USES_MALLOC +/* BACKTRACE_SUPPORTS_THREADS will be #define'd as 1 if the backtrace + library is configured with threading support, 0 if not. If this is + 0, the threaded parameter to backtrace_create_state must be passed + as 0. */ +#cmakedefine01 BACKTRACE_SUPPORTS_THREADS +/* BACKTRACE_SUPPORTS_DATA will be #defined'd as 1 if the backtrace_syminfo + will work for variables. It will always work for functions. */ +#cmakedefine01 BACKTRACE_SUPPORTS_DATA \ No newline at end of file diff --git a/cmake/libbacktraceConfig.cmake b/cmake/libbacktraceConfig.cmake new file mode 100644 index 0000000..5083f1c --- /dev/null +++ b/cmake/libbacktraceConfig.cmake @@ -0,0 +1,14 @@ +# Usage: +# +#find_package(libbacktrace REQUIRED) +#include_directories(${libbacktrace_INCLUDE_DIRS}) +#target_link_libraries(app libbacktrace) + +if(libbacktrace_CONFIG_INCLUDED) + return() +endif() +set(libbacktrace_CONFIG_INCLUDED TRUE) + +get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) +include(${SELF_DIR}/libbacktrace-targets.cmake) +get_filename_component(libbacktrace_INCLUDE_DIRS "${SELF_DIR}/.." ABSOLUTE) \ No newline at end of file diff --git a/cmake/libbacktraceConfigVersion.cmake b/cmake/libbacktraceConfigVersion.cmake new file mode 100644 index 0000000..e9aac3f --- /dev/null +++ b/cmake/libbacktraceConfigVersion.cmake @@ -0,0 +1,21 @@ +set(PACKAGE_VERSION "1.0.0") + +if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + if(PACKAGE_VERSION MATCHES "^([0-9]+)\\.") + set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}") + else() + set(CVF_VERSION_MAJOR PACKAGE_VERSION) + endif() + + if(PACKAGE_FIND_VERSION_MAJOR STREQUAL CVF_VERSION_MAJOR) + set(PACKAGE_VERSION_COMPATIBLE TRUE) + else() + set(PACKAGE_VERSION_COMPATIBLE FALSE) + endif() + + if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) + set(PACKAGE_VERSION_EXACT TRUE) + endif() +endif() \ No newline at end of file diff --git a/config.h.cmake b/config.h.cmake new file mode 100644 index 0000000..de6a4db --- /dev/null +++ b/config.h.cmake @@ -0,0 +1,58 @@ +/* config.h.cmake */ +/* ELF size: 32 or 64 */ +#cmakedefine BACKTRACE_ELF_SIZE +/* XCOFF size: 32 or 64 */ +#cmakedefine BACKTRACE_XCOFF_SIZE +/* Define to 1 if you have the __atomic functions */ +#cmakedefine HAVE_ATOMIC_FUNCTIONS 1 +/* Define to 1 if you have the `clock_gettime' function. */ +#cmakedefine HAVE_CLOCK_GETTIME 1 +/* Define to 1 if you have the declaration of `strnlen', and to 0 if you + don't. */ +#cmakedefine HAVE_DECL_STRNLEN 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_DLFCN_H 1 +/* Define if dl_iterate_phdr is available. */ +#cmakedefine HAVE_DL_ITERATE_PHDR 1 +/* Define to 1 if you have the fcntl function */ +#cmakedefine HAVE_FCNTL 1 +/* Define if getexecname is available. */ +#cmakedefine HAVE_GETEXECNAME 1 +/* Define if _Unwind_GetIPInfo is available. */ +#cmakedefine HAVE_GETIPINFO 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_INTTYPES_H 1 +/* Define to 1 if you have the `z' library (-lz). */ +#cmakedefine HAVE_LIBZ 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_LINK_H 1 +/* Define if AIX loadquery is available. */ +#cmakedefine HAVE_LOADQUERY 1 +/* Define to 1 if you have the `lstat' function. */ +#cmakedefine HAVE_LSTAT 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_MEMORY_H 1 +/* Define to 1 if you have the `readlink' function. */ +#cmakedefine HAVE_READLINK 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STDINT_H 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STDLIB_H 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STRINGS_H 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STRING_H 1 +/* Define to 1 if you have the __sync functions */ +#cmakedefine HAVE_SYNC_FUNCTIONS 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_LDR_H 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_MMAN_H 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_STAT_H 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_TYPES_H 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_UNISTD_H 1 +/* Define if -lz is available. */ +#cmakedefine HAVE_ZLIB 1 From b08cb334d21f73ba0d62ed4aaa928cbf88bf76d5 Mon Sep 17 00:00:00 2001 From: KaiN Date: Tue, 17 Jul 2018 08:36:24 +0200 Subject: [PATCH 2/9] generated headers ar now placed in build dir, added -frandom-seed note --- CMakeLists.txt | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 94d0425..d66f6f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.5) project(backtrace) +# Automake uses -frandom-seed initialized with file name of given file +# but AFAIK it can't be done on CMake, so here's always same seed set(CMAKE_CXX_FLAGS "-DHAVE_CONFIG_H -funwind-tables -frandom-seed=mySeed -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wmissing-format-attribute -Wcast-qual -g -O2") set(CMAKE_C_FLAGS "-DHAVE_CONFIG_H -funwind-tables -frandom-seed=mySeed -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wmissing-format-attribute -Wcast-qual -g -O2") @@ -10,10 +12,12 @@ file(GLOB sources simple.c pecoff.c read.c alloc.c config.h ) file(GLOB export_headers - backtrace.h backtrace-supported.h + ${CMAKE_CURRENT_BINARY_DIR}/backtrace.h + ${CMAKE_CURRENT_BINARY_DIR}/backtrace-supported.h ) -add_library(${PROJECT_NAME} ${sources}) +add_library(${PROJECT_NAME} ${sources} ${export_headers}) +include_directories(${PROJECT_NAME} ${CMAKE_CURRENT_BINARY_DIR}) if(CMAKE_COMPILER_IS_GNUCC) set(BACKTRACE_SUPPORTED 1) @@ -74,11 +78,11 @@ endif() # Generate backtrace-supported.h and config.h configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/backtrace-supported.h.cmake - ${CMAKE_CURRENT_SOURCE_DIR}/backtrace-supported.h + ${CMAKE_CURRENT_BINARY_DIR}/backtrace-supported.h ) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake - ${CMAKE_CURRENT_SOURCE_DIR}/config.h + ${CMAKE_CURRENT_BINARY_DIR}/config.h ) #install libbacktrace and header files @@ -92,9 +96,11 @@ install(TARGETS ${PROJECT_NAME} EXPORT lib${PROJECT_NAME}-targets ) install(EXPORT lib${PROJECT_NAME}-targets DESTINATION ${INSTALL_CMAKE_DIR}) -install(FILES ${CMAKE_SOURCE_DIR}/cmake/lib${PROJECT_NAME}Config.cmake -${CMAKE_SOURCE_DIR}/cmake/lib${PROJECT_NAME}ConfigVersion.cmake -DESTINATION ${INSTALL_CMAKE_DIR}) +install(FILES + ${CMAKE_SOURCE_DIR}/cmake/lib${PROJECT_NAME}Config.cmake + ${CMAKE_SOURCE_DIR}/cmake/lib${PROJECT_NAME}ConfigVersion.cmake + DESTINATION ${INSTALL_CMAKE_DIR} +) install(TARGETS ${PROJECT_NAME} DESTINATION "${INSTALL_LIB_DIR}") install(FILES ${export_headers} DESTINATION "${INSTALL_INCLUDE_DIR}") From 9f5df7e3f69e9caaca4234d7e94a5a9fc28e9c4a Mon Sep 17 00:00:00 2001 From: KaiN Date: Tue, 17 Jul 2018 17:09:08 +0200 Subject: [PATCH 3/9] Removed backtrace-supported.h.cmake --- CMakeLists.txt | 5 +++- backtrace-supported.h.cmake | 51 ------------------------------------- 2 files changed, 4 insertions(+), 52 deletions(-) delete mode 100644 backtrace-supported.h.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index d66f6f7..a0b3be0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -76,8 +76,11 @@ else() endif() # Generate backtrace-supported.h and config.h +# backtrace-supported.h.in has syntax which works with CMake out of the box so +# let's not duplicate things unnecessarily. +# config.h.in ain't parsed properly so we need slightly different version. configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/backtrace-supported.h.cmake + ${CMAKE_CURRENT_SOURCE_DIR}/backtrace-supported.h.in ${CMAKE_CURRENT_BINARY_DIR}/backtrace-supported.h ) configure_file( diff --git a/backtrace-supported.h.cmake b/backtrace-supported.h.cmake deleted file mode 100644 index 8e76ea0..0000000 --- a/backtrace-supported.h.cmake +++ /dev/null @@ -1,51 +0,0 @@ -/* backtrace-supported.h.cmake -- Whether stack backtrace is supported. - Copyright (C) 2012-2016 Free Software Foundation, Inc. - Based backtrace-supported.h.in, written by Ian Lance Taylor, Google. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - (1) Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - (2) 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. - (3) The name of the author may not be used to - endorse or promote products derived from this software without - specific prior written permission. -THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. */ -/* The file backtrace-supported.h.in is used by configure to generate - the file backtrace-supported.h. The file backtrace-supported.h may - be #include'd to see whether the backtrace library will be able to - get a backtrace and produce symbolic information. */ -/* BACKTRACE_SUPPORTED will be #define'd as 1 if the backtrace library - should work, 0 if it will not. Libraries may #include this to make - other arrangements. */ -#cmakedefine01 BACKTRACE_SUPPORTED -/* BACKTRACE_USES_MALLOC will be #define'd as 1 if the backtrace - library will call malloc as it works, 0 if it will call mmap - instead. This may be used to determine whether it is safe to call - the backtrace functions from a signal handler. In general this - only applies to calls like backtrace and backtrace_pcinfo. It does - not apply to backtrace_simple, which never calls malloc. It does - not apply to backtrace_print, which always calls fprintf and - therefore malloc. */ -#cmakedefine01 BACKTRACE_USES_MALLOC -/* BACKTRACE_SUPPORTS_THREADS will be #define'd as 1 if the backtrace - library is configured with threading support, 0 if not. If this is - 0, the threaded parameter to backtrace_create_state must be passed - as 0. */ -#cmakedefine01 BACKTRACE_SUPPORTS_THREADS -/* BACKTRACE_SUPPORTS_DATA will be #defined'd as 1 if the backtrace_syminfo - will work for variables. It will always work for functions. */ -#cmakedefine01 BACKTRACE_SUPPORTS_DATA \ No newline at end of file From 28d7445d5b8d4bb186807a402c56740001fd30c1 Mon Sep 17 00:00:00 2001 From: KaiN Date: Wed, 18 Jul 2018 12:25:17 +0200 Subject: [PATCH 4/9] Removed things I've added to .gitignore --- .gitignore | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 791ab25..ecf0733 100644 --- a/.gitignore +++ b/.gitignore @@ -2,9 +2,4 @@ *.o *.lo *.a -*.la - -backtrace-supported\.h - -config\.h - +*.la From cd6f82fea7ca4612e68bb9815335a482831940a6 Mon Sep 17 00:00:00 2001 From: KaiN Date: Fri, 8 Feb 2019 10:05:32 +0100 Subject: [PATCH 5/9] fix for builds outside source tree --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a0b3be0..cd995f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ file(GLOB sources simple.c pecoff.c read.c alloc.c config.h ) file(GLOB export_headers - ${CMAKE_CURRENT_BINARY_DIR}/backtrace.h + ${CMAKE_CURRENT_SOURCE_DIR}/backtrace.h ${CMAKE_CURRENT_BINARY_DIR}/backtrace-supported.h ) From b3b27a5c18726a052b564a3d6fb9ea299f22fc64 Mon Sep 17 00:00:00 2001 From: KaiN Date: Mon, 11 Feb 2019 09:22:43 +0100 Subject: [PATCH 6/9] removed GLOB 'cuz it messes with backtrace-supported.h install and it's redundant --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cd995f4..44e46ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,11 +7,11 @@ project(backtrace) set(CMAKE_CXX_FLAGS "-DHAVE_CONFIG_H -funwind-tables -frandom-seed=mySeed -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wmissing-format-attribute -Wcast-qual -g -O2") set(CMAKE_C_FLAGS "-DHAVE_CONFIG_H -funwind-tables -frandom-seed=mySeed -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wmissing-format-attribute -Wcast-qual -g -O2") -file(GLOB sources +set(sources atomic.c dwarf.c fileline.c posix.c print.c sort.c state.c backtrace.c simple.c pecoff.c read.c alloc.c config.h ) -file(GLOB export_headers +set(export_headers ${CMAKE_CURRENT_SOURCE_DIR}/backtrace.h ${CMAKE_CURRENT_BINARY_DIR}/backtrace-supported.h ) From fa2fe5e50784a3fb19296d7d760a884d7d0b4cae Mon Sep 17 00:00:00 2001 From: KaiN Date: Mon, 11 Feb 2019 17:04:32 +0100 Subject: [PATCH 7/9] cmake compile & install works on ubuntu 16.04 --- CMakeLists.txt | 412 ++++++++++++++++++++++++++++++++++++------------- config.h.cmake | 23 ++- 2 files changed, 325 insertions(+), 110 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 44e46ff..5c6921d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,109 +1,303 @@ -cmake_minimum_required(VERSION 3.5) - -project(backtrace) - -# Automake uses -frandom-seed initialized with file name of given file -# but AFAIK it can't be done on CMake, so here's always same seed -set(CMAKE_CXX_FLAGS "-DHAVE_CONFIG_H -funwind-tables -frandom-seed=mySeed -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wmissing-format-attribute -Wcast-qual -g -O2") -set(CMAKE_C_FLAGS "-DHAVE_CONFIG_H -funwind-tables -frandom-seed=mySeed -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wmissing-format-attribute -Wcast-qual -g -O2") - -set(sources - atomic.c dwarf.c fileline.c posix.c print.c sort.c state.c backtrace.c - simple.c pecoff.c read.c alloc.c config.h -) -set(export_headers - ${CMAKE_CURRENT_SOURCE_DIR}/backtrace.h - ${CMAKE_CURRENT_BINARY_DIR}/backtrace-supported.h -) - -add_library(${PROJECT_NAME} ${sources} ${export_headers}) -include_directories(${PROJECT_NAME} ${CMAKE_CURRENT_BINARY_DIR}) - -if(CMAKE_COMPILER_IS_GNUCC) - set(BACKTRACE_SUPPORTED 1) - - # Assume multi-threaded environment - set(BACKTRACE_SUPPORTS_THREADS 1) - - # Assume ELF/DWARF, meaning that BACKTRACE_SUPPORTS_DATA is hard-coded on. - set(BACKTRACE_SUPPORTS_DATA 1) - - find_package(ZLIB) - if(ZLIB_FOUND) - SET(HAVE_LIBZ 1) - SET(HAVE_ZLIB 1) - target_link_libraries(${PROJECT_NAME} z) - else() - SET(HAVE_LIBZ 0) - SET(HAVE_ZLIB 0) - endif() - - if(WIN32) - # Typical MinGW config - # DWARF2 exception handling could be detected based on parsing gcc --version - set(BACKTRACE_USES_MALLOC 1) - SET(BACKTRACE_ELF_SIZE unused) - SET(BACKTRACE_XCOFF_SIZE unused) - SET(HAVE_ATOMIC_FUNCTIONS 1) - SET(HAVE_CLOCK_GETTIME 1) - SET(HAVE_DECL_STRNLEN 1) - SET(HAVE_DLFCN_H 0) - SET(HAVE_DL_ITERATE_PHDR 0) - SET(HAVE_FCNTL 0) - SET(HAVE_GETEXECNAME 0) - SET(HAVE_GETIPINFO 1) - SET(HAVE_INTTYPES_H 1) - SET(HAVE_LINK_H 0) - SET(HAVE_LOADQUERY 0) - SET(HAVE_LSTAT 0) - SET(HAVE_MEMORY_H 1) - SET(HAVE_READLINK 0) - SET(HAVE_STDINT_H 1) - SET(HAVE_STDLIB_H 1) - SET(HAVE_STRINGS_H 1) - SET(HAVE_STRING_H 1) - SET(HAVE_SYNC_FUNCTIONS 1) - SET(HAVE_SYS_LDR_H 0) - SET(HAVE_SYS_MMAN_H 0) - SET(HAVE_SYS_STAT_H 1) - SET(HAVE_SYS_TYPES_H 1) - SET(HAVE_UNISTD_H 1) - else() - set(BACKTRACE_SUPPORTED 0) - endif() -else() - set(BACKTRACE_SUPPORTED 0) -endif() - -# Generate backtrace-supported.h and config.h -# backtrace-supported.h.in has syntax which works with CMake out of the box so -# let's not duplicate things unnecessarily. -# config.h.in ain't parsed properly so we need slightly different version. -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/backtrace-supported.h.in - ${CMAKE_CURRENT_BINARY_DIR}/backtrace-supported.h -) -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake - ${CMAKE_CURRENT_BINARY_DIR}/config.h -) - -#install libbacktrace and header files -set(INSTALL_LIB_DIR lib/libbacktrace) -set(INSTALL_INCLUDE_DIR include/libbacktrace) -set(INSTALL_CMAKE_DIR CMake) - -# Install CMake files -install(TARGETS ${PROJECT_NAME} - DESTINATION ${INSTALL_LIB_DIR} - EXPORT lib${PROJECT_NAME}-targets -) -install(EXPORT lib${PROJECT_NAME}-targets DESTINATION ${INSTALL_CMAKE_DIR}) -install(FILES - ${CMAKE_SOURCE_DIR}/cmake/lib${PROJECT_NAME}Config.cmake - ${CMAKE_SOURCE_DIR}/cmake/lib${PROJECT_NAME}ConfigVersion.cmake - DESTINATION ${INSTALL_CMAKE_DIR} -) - -install(TARGETS ${PROJECT_NAME} DESTINATION "${INSTALL_LIB_DIR}") -install(FILES ${export_headers} DESTINATION "${INSTALL_INCLUDE_DIR}") +cmake_minimum_required(VERSION 3.5) + +project(backtrace C) + +# This file is a work in progress - some things may be broken, +#so feel free to fix 'em by looking at configure.ac + +# Automake uses -frandom-seed initialized with file name of given file +# but AFAIK it can't be done on CMake, so here's always same seed +set(CMAKE_CXX_FLAGS "-DHAVE_CONFIG_H -funwind-tables -frandom-seed=mySeed -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wmissing-format-attribute -Wcast-qual -g -O2") +set(CMAKE_C_FLAGS "-DHAVE_CONFIG_H -funwind-tables -frandom-seed=mySeed -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wmissing-format-attribute -Wcast-qual -g -O2") + +set(sources + atomic.c dwarf.c fileline.c posix.c print.c sort.c state.c config.h +) +set(export_headers + ${CMAKE_CURRENT_SOURCE_DIR}/backtrace.h + ${CMAKE_CURRENT_BINARY_DIR}/backtrace-supported.h +) + +if(CMAKE_COMPILER_IS_GNUCC) + set(_GNU_SOURCE 1) + set(BACKTRACE_SUPPORTED 1) + + # Assume multi-threaded environment + set(BACKTRACE_SUPPORTS_THREADS 1) + + # Assume ELF/DWARF, meaning that BACKTRACE_SUPPORTS_DATA is hard-coded on. + set(BACKTRACE_SUPPORTS_DATA 1) + + find_package(ZLIB) + if(ZLIB_FOUND) + set(HAVE_LIBZ 1) + set(HAVE_ZLIB 1) + else() + set(HAVE_LIBZ 0) + set(HAVE_ZLIB 0) + endif() + + if(WIN32) + # Typical MinGW config + # DWARF2 exception handling could be detected based on parsing gcc --version + set(BACKTRACE_USES_MALLOC 1) + set(BACKTRACE_ELF_SIZE unused) + set(BACKTRACE_XCOFF_SIZE unused) + + # TODO do those tests using CMake + set(HAVE_ATOMIC_FUNCTIONS 1) + set(HAVE_CLOCK_GETTIME 1) + set(HAVE_DECL_STRNLEN 1) + set(HAVE_DLFCN_H 0) + set(HAVE_DL_ITERATE_PHDR 0) + set(HAVE_FCNTL 0) + set(HAVE_GETEXECNAME 0) + set(HAVE_GETIPINFO 1) + set(HAVE_INTTYPES_H 1) + set(HAVE_LINK_H 0) + set(HAVE_LOADQUERY 0) + set(HAVE_LSTAT 0) + set(HAVE_MEMORY_H 1) + set(HAVE_READLINK 0) + set(HAVE_STDINT_H 1) + set(HAVE_STDLIB_H 1) + set(HAVE_STRINGS_H 1) + set(HAVE_STRING_H 1) + set(HAVE_SYNC_FUNCTIONS 1) + set(HAVE_SYS_LDR_H 0) + set(HAVE_SYS_MMAN_H 0) + set(HAVE_SYS_STAT_H 1) + set(HAVE_SYS_TYPES_H 1) + set(HAVE_UNISTD_H 1) + + set(sources "${sources};backtrace.c;simple.c") + set(FORMAT_FILE "pecoff.c") + set(VIEW_FILE "read.c") + set(ALLOC_FILE "alloc.c") + else() + # TODO make this code work on Windows - it's proper configure replacement + include(CheckIncludeFiles) + include(CheckFunctionExists) + include(CheckCSourceCompiles) + include(CheckLibraryExists) + include(CheckCCompilerFlag) + + # Check some headers + check_include_files("unistd.h" HAVE_UNISTD_H) + check_include_files("sys/types.h" HAVE_SYS_TYPES_H) + check_include_files("sys/stat.h" HAVE_SYS_STAT_H) + check_include_files("string.h" HAVE_STRING_H) + check_include_files("strings.h" HAVE_STRINGS_H) + check_include_files("stdlib.h" HAVE_STDLIB_H) + check_include_files("stdint.h" HAVE_STDINT_H) + check_include_files("inttypes.h" HAVE_INTTYPES_H) + check_include_files("memory.h" HAVE_MEMORY_H) + check_include_files("dlfcn.h" HAVE_DLFCN_H) + + # Check some functions + check_function_exists( + "readlink" HAVE_READLINK CMAKE_REQUIRED_INCLUDES "unistd.h" + ) + check_function_exists( + "lstat" HAVE_READLINK CMAKE_REQUIRED_INCLUDES "sys/stat.h" + ) + check_function_exists( + "strnlen" HAVE_DECL_STRNLEN CMAKE_REQUIRED_INCLUDES "string.h" + ) + + # Check unwind + check_include_files("unwind.h" UNWIND_HEADER_FOUND) + check_function_exists( + "_Unwind_Backtrace" UNWIND_FN_FOUND CMAKE_REQUIRED_INCLUDES + ) + if((${UNWIND_HEADER_FOUND}) AND (${UNWIND_FN_FOUND})) + set(sources "${sources};backtrace.c;simple.c") + else() + set(sources "${sources};nounwind.c") + set(BACKTRACE_SUPPORTED 0) + endif() + + # Check UnwindGetIPInfo + set(oldFlags ${CMAKE_REQUIRED_FLAGS}) + set(CMAKE_REQUIRED_FLAGS "-Werror-implicit-function-declaration") + check_c_source_compiles(" + #include \"unwind.h\" + + struct _Unwind_Context *context; + int ip_before_insn = 0; + + int main(void) { + return _Unwind_GetIPInfo (context, &ip_before_insn); + } + " HAVE_GETIPINFO) + set(CMAKE_REQUIRED_FLAGS ${oldFlags}) + + set(oldFlags ${CMAKE_REQUIRED_FLAGS}) + set(CMAKE_REQUIRED_FLAGS "-funwind-tables") + CHECK_C_COMPILER_FLAG("" unwind_tables_supported) + if(unwind_tables_supported) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -funwind-tables") + endif() + set(CMAKE_REQUIRED_FLAGS ${oldFlags}) + + # Check threads + # TODO configure.ac checks hppa*-*-hpux* stuff, dunno what it is + check_c_source_compiles(" + int i; + int main(void) { + __sync_bool_compare_and_swap (&i, i, i); + __sync_lock_test_and_set (&i, 1); + __sync_lock_release (&i); + return 0; + } + " HAVE_SYNC_FUNCTIONS) + if(${HAVE_SYNC_FUNCTIONS}) + set(BACKTRACE_SUPPORTS_THREADS 1) + endif() + + # Check __atomic support + check_c_source_compiles(" + int i; + int main(void) { + __atomic_load_n (&i, __ATOMIC_ACQUIRE); + __atomic_store_n (&i, 1, __ATOMIC_RELEASE); + return 0; + } + " HAVE_ATOMIC_FUNCTIONS) + + # The library needs to be able to read the executable itself. + # Determine executable format (elf32/elf64/pecoff) + if((${CMAKE_EXECUTABLE_FORMAT} STREQUAL "ELF")) + math(EXPR BACKTRACE_ELF_SIZE "${CMAKE_SIZEOF_VOID_P} * 8") + set(filetype "elf${BACKTRACE_ELF_SIZE}") + set(FORMAT_FILE "elf.c") + set(BACKTRACE_SUPPORTS_DATA 1) + else() + # TODO detect pecoff/xcoff in some way - especially on MinGW + message( + FATAL_ERROR "Unknown executable format: '${CMAKE_EXECUTABLE_FORMAT}'" + ) + endif() + message(STATUS "Executable format: ${filetype}") + + # mmap support + check_include_files("sys/mman.h" HAVE_SYS_MMAN_H) + if(HAVE_SYS_MMAN_H) + # TODO port from configure.ac: spu-*-*|*-*-msdosdjgpp + check_function_exists( + "mmap" have_mmap CMAKE_REQUIRED_INCLUDES "sys/mman.h" + ) + endif() + if(NOT have_mmap) + set(VIEW_FILE "read.c") + set(ALLOC_FILE "alloc.c") + else() + set(VIEW_FILE "mmapio.c") + check_c_source_compiles(" + #include + #if !defined(MAP_ANONYMOUS) && !defined(MAP_ANON) + #error no MAP_ANONYMOUS + #endif + " use_mmap_for_alloc) + if(use_mmap_for_alloc) + set(ALLOC_FILE "mmap.c") + else() + set(ALLOC_FILE "alloc.c") + endif() + if(${ALLOC_FILE} STREQUAL "alloc.c") + SET(BACKTRACE_USES_MALLOC 1) + else() + SET(BACKTRACE_USES_MALLOC 0) + endif() + + # Check for dl_iterate_phdr + check_include_files("link.h" HAVE_LINK_H) + if(HAVE_LINK_H) + # TODO port from configure.ac: *-*-solaris2.10* + check_function_exists( + "dl_iterate_phdr" HAVE_DL_ITERATE_PHDR + CMAKE_REQUIRED_INCLUDES "link.h" + ) + endif() + + # Check for loadquery. + check_include_files("sys/ldr.h" HAVE_SYS_LDR_H) + check_function_exists( + "loadquery" HAVE_LOADQUERY CMAKE_REQUIRED_INCLUDES "sys/ldr.h" + ) + + # Check for fcntl function. + check_function_exists( + "fcntl" HAVE_FCNTL CMAKE_REQUIRED_INCLUDES "fcntl.h" + ) + + # Check for getexecname function. + check_function_exists( + "getexecname" HAVE_GETEXECNAME CMAKE_REQUIRED_INCLUDES "stdlib.h" + ) + + # Check for the clock_gettime function. + check_library_exists(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME) + if (HAVE_CLOCK_GETTIME) + set(CLOCK_GETTIME_LINK "-lrt") + else() + # might also be in libc + check_library_exists(c clock_gettime "" HAVE_CLOCK_GETTIME) + endif() + + # Test whether the compiler supports the -pthread option + set(CMAKE_THREAD_PREFER_PTHREAD ON) + set(THREADS_PREFER_PTHREAD_FLAG ON) + find_package(Threads) + if(CMAKE_USE_PTHREADS_INIT) + set(HAVE_PTHREAD 1) + endif() + endif() + endif() +else() + set(BACKTRACE_SUPPORTED 0) +endif() + +# Generate backtrace-supported.h and config.h +# backtrace-supported.h.in has syntax which works with CMake out of the box so +# let's not duplicate things unnecessarily. +# config.h.in ain't parsed properly so we need slightly different version. +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/backtrace-supported.h.in + ${CMAKE_CURRENT_BINARY_DIR}/backtrace-supported.h +) +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake + ${CMAKE_CURRENT_BINARY_DIR}/config.h +) + +# Build commands +add_library(backtrace ${sources} ${FORMAT_FILE} ${VIEW_FILE} ${ALLOC_FILE} ${export_headers}) +include_directories(backtrace ${CMAKE_CURRENT_BINARY_DIR}) +target_link_libraries(backtrace ${CLOCK_GETTIME_LINK}) +if(CMAKE_USE_PTHREADS_INIT) + target_link_libraries(backtrace ${CMAKE_THREAD_LIBS_INIT}) +endif() +if(ZLIB_FOUND) + target_link_libraries(backtrace z) +endif() + +#install libbacktrace and header files +set(INSTALL_LIB_DIR lib/libbacktrace) +set(INSTALL_INCLUDE_DIR include/libbacktrace) +set(INSTALL_CMAKE_DIR CMake) + +# Install CMake files +install(TARGETS backtrace + DESTINATION ${INSTALL_LIB_DIR} + EXPORT libbacktrace-targets +) +install(EXPORT libbacktrace-targets DESTINATION ${INSTALL_CMAKE_DIR}) +install(FILES + ${CMAKE_SOURCE_DIR}/cmake/libbacktraceConfig.cmake + ${CMAKE_SOURCE_DIR}/cmake/libbacktraceConfigVersion.cmake + DESTINATION ${INSTALL_CMAKE_DIR} +) + +install(TARGETS backtrace DESTINATION "${INSTALL_LIB_DIR}") +install(FILES ${export_headers} DESTINATION "${INSTALL_INCLUDE_DIR}") diff --git a/config.h.cmake b/config.h.cmake index de6a4db..b7b3f2b 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -1,6 +1,6 @@ /* config.h.cmake */ /* ELF size: 32 or 64 */ -#cmakedefine BACKTRACE_ELF_SIZE +#cmakedefine BACKTRACE_ELF_SIZE @BACKTRACE_ELF_SIZE@ /* XCOFF size: 32 or 64 */ #cmakedefine BACKTRACE_XCOFF_SIZE /* Define to 1 if you have the __atomic functions */ @@ -56,3 +56,24 @@ #cmakedefine HAVE_UNISTD_H 1 /* Define if -lz is available. */ #cmakedefine HAVE_ZLIB 1 + +/* Enable extensions on AIX 3, Interix. */ +#ifndef _ALL_SOURCE +#cmakedefine _ALL_SOURCE +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +#cmakedefine _GNU_SOURCE +#endif +/* Enable threading extensions on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +#cmakedefine _POSIX_PTHREAD_SEMANTICS +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +#cmakedefine _TANDEM_SOURCE +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +#cmakedefine __EXTENSIONS__ +#endif From e653f865103b02525f0bdfd2d5db4fad3b1dc0da Mon Sep 17 00:00:00 2001 From: KaiN Date: Thu, 21 Feb 2019 12:39:55 +0100 Subject: [PATCH 8/9] fix for case where ${CMAKE_EXECUTABLE_FORMAT} isn't set to any value --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5c6921d..9f8bdd7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -167,7 +167,7 @@ if(CMAKE_COMPILER_IS_GNUCC) # The library needs to be able to read the executable itself. # Determine executable format (elf32/elf64/pecoff) - if((${CMAKE_EXECUTABLE_FORMAT} STREQUAL "ELF")) + if(("${CMAKE_EXECUTABLE_FORMAT}" STREQUAL "ELF")) math(EXPR BACKTRACE_ELF_SIZE "${CMAKE_SIZEOF_VOID_P} * 8") set(filetype "elf${BACKTRACE_ELF_SIZE}") set(FORMAT_FILE "elf.c") From c6c1ce21ea3a94bc4397cfdef894f39cdf2568e4 Mon Sep 17 00:00:00 2001 From: "Zhao, Yang2" Date: Wed, 20 Mar 2024 05:16:34 -0700 Subject: [PATCH 9/9] add copyright --- .gitignore | 2 +- CMakeLists.txt | 492 ++++++++++++++------------ cmake/libbacktraceConfig.cmake | 33 +- cmake/libbacktraceConfigVersion.cmake | 33 +- 4 files changed, 325 insertions(+), 235 deletions(-) diff --git a/.gitignore b/.gitignore index ecf0733..86a40a0 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,4 @@ *.o *.lo *.a -*.la +*.la diff --git a/CMakeLists.txt b/CMakeLists.txt index 9f8bdd7..2f271dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,3 +1,34 @@ +# CMakeLists.txt -- Backtrace configure script. +# Copyright (C) 2012-2018 Free Software Foundation, Inc. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# (1) Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# (2) 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. +# +# (3) The name of the author may not be used to +# endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. + cmake_minimum_required(VERSION 3.5) project(backtrace C) @@ -11,251 +42,248 @@ set(CMAKE_CXX_FLAGS "-DHAVE_CONFIG_H -funwind-tables -frandom-seed=mySeed -W -Wa set(CMAKE_C_FLAGS "-DHAVE_CONFIG_H -funwind-tables -frandom-seed=mySeed -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wmissing-format-attribute -Wcast-qual -g -O2") set(sources - atomic.c dwarf.c fileline.c posix.c print.c sort.c state.c config.h + atomic.c dwarf.c fileline.c posix.c print.c sort.c state.c config.h ) set(export_headers - ${CMAKE_CURRENT_SOURCE_DIR}/backtrace.h - ${CMAKE_CURRENT_BINARY_DIR}/backtrace-supported.h + ${CMAKE_CURRENT_SOURCE_DIR}/backtrace.h + ${CMAKE_CURRENT_BINARY_DIR}/backtrace-supported.h ) if(CMAKE_COMPILER_IS_GNUCC) - set(_GNU_SOURCE 1) - set(BACKTRACE_SUPPORTED 1) - - # Assume multi-threaded environment - set(BACKTRACE_SUPPORTS_THREADS 1) + set(_GNU_SOURCE 1) + set(BACKTRACE_SUPPORTED 1) + + # Assume multi-threaded environment + set(BACKTRACE_SUPPORTS_THREADS 1) - # Assume ELF/DWARF, meaning that BACKTRACE_SUPPORTS_DATA is hard-coded on. - set(BACKTRACE_SUPPORTS_DATA 1) - - find_package(ZLIB) - if(ZLIB_FOUND) - set(HAVE_LIBZ 1) - set(HAVE_ZLIB 1) - else() - set(HAVE_LIBZ 0) - set(HAVE_ZLIB 0) - endif() - - if(WIN32) - # Typical MinGW config - # DWARF2 exception handling could be detected based on parsing gcc --version - set(BACKTRACE_USES_MALLOC 1) - set(BACKTRACE_ELF_SIZE unused) - set(BACKTRACE_XCOFF_SIZE unused) + # Assume ELF/DWARF, meaning that BACKTRACE_SUPPORTS_DATA is hard-coded on. + set(BACKTRACE_SUPPORTS_DATA 1) + + find_package(ZLIB) + if(ZLIB_FOUND) + set(HAVE_LIBZ 1) + set(HAVE_ZLIB 1) + else() + set(HAVE_LIBZ 0) + set(HAVE_ZLIB 0) + endif() + + if(WIN32) + # Typical MinGW config + # DWARF2 exception handling could be detected based on parsing gcc --version + set(BACKTRACE_USES_MALLOC 1) + set(BACKTRACE_ELF_SIZE unused) + set(BACKTRACE_XCOFF_SIZE unused) - # TODO do those tests using CMake - set(HAVE_ATOMIC_FUNCTIONS 1) - set(HAVE_CLOCK_GETTIME 1) - set(HAVE_DECL_STRNLEN 1) - set(HAVE_DLFCN_H 0) - set(HAVE_DL_ITERATE_PHDR 0) - set(HAVE_FCNTL 0) - set(HAVE_GETEXECNAME 0) - set(HAVE_GETIPINFO 1) - set(HAVE_INTTYPES_H 1) - set(HAVE_LINK_H 0) - set(HAVE_LOADQUERY 0) - set(HAVE_LSTAT 0) - set(HAVE_MEMORY_H 1) - set(HAVE_READLINK 0) - set(HAVE_STDINT_H 1) - set(HAVE_STDLIB_H 1) - set(HAVE_STRINGS_H 1) - set(HAVE_STRING_H 1) - set(HAVE_SYNC_FUNCTIONS 1) - set(HAVE_SYS_LDR_H 0) - set(HAVE_SYS_MMAN_H 0) - set(HAVE_SYS_STAT_H 1) - set(HAVE_SYS_TYPES_H 1) - set(HAVE_UNISTD_H 1) + # TODO do those tests using CMake + set(HAVE_ATOMIC_FUNCTIONS 1) + set(HAVE_CLOCK_GETTIME 1) + set(HAVE_DECL_STRNLEN 1) + set(HAVE_DLFCN_H 0) + set(HAVE_DL_ITERATE_PHDR 0) + set(HAVE_FCNTL 0) + set(HAVE_GETEXECNAME 0) + set(HAVE_GETIPINFO 1) + set(HAVE_INTTYPES_H 1) + set(HAVE_LINK_H 0) + set(HAVE_LOADQUERY 0) + set(HAVE_LSTAT 0) + set(HAVE_MEMORY_H 1) + set(HAVE_READLINK 0) + set(HAVE_STDINT_H 1) + set(HAVE_STDLIB_H 1) + set(HAVE_STRINGS_H 1) + set(HAVE_STRING_H 1) + set(HAVE_SYNC_FUNCTIONS 1) + set(HAVE_SYS_LDR_H 0) + set(HAVE_SYS_MMAN_H 0) + set(HAVE_SYS_STAT_H 1) + set(HAVE_SYS_TYPES_H 1) + set(HAVE_UNISTD_H 1) - set(sources "${sources};backtrace.c;simple.c") - set(FORMAT_FILE "pecoff.c") - set(VIEW_FILE "read.c") - set(ALLOC_FILE "alloc.c") - else() - # TODO make this code work on Windows - it's proper configure replacement - include(CheckIncludeFiles) - include(CheckFunctionExists) - include(CheckCSourceCompiles) - include(CheckLibraryExists) - include(CheckCCompilerFlag) + set(sources "${sources};backtrace.c;simple.c") + set(FORMAT_FILE "pecoff.c") + set(VIEW_FILE "read.c") + set(ALLOC_FILE "alloc.c") + else() + # TODO make this code work on Windows - it's proper configure replacement + include(CheckIncludeFiles) + include(CheckFunctionExists) + include(CheckCSourceCompiles) + include(CheckLibraryExists) + include(CheckCCompilerFlag) - # Check some headers - check_include_files("unistd.h" HAVE_UNISTD_H) - check_include_files("sys/types.h" HAVE_SYS_TYPES_H) - check_include_files("sys/stat.h" HAVE_SYS_STAT_H) - check_include_files("string.h" HAVE_STRING_H) - check_include_files("strings.h" HAVE_STRINGS_H) - check_include_files("stdlib.h" HAVE_STDLIB_H) - check_include_files("stdint.h" HAVE_STDINT_H) - check_include_files("inttypes.h" HAVE_INTTYPES_H) - check_include_files("memory.h" HAVE_MEMORY_H) - check_include_files("dlfcn.h" HAVE_DLFCN_H) + # Check some headers + check_include_files("unistd.h" HAVE_UNISTD_H) + check_include_files("sys/types.h" HAVE_SYS_TYPES_H) + check_include_files("sys/stat.h" HAVE_SYS_STAT_H) + check_include_files("string.h" HAVE_STRING_H) + check_include_files("strings.h" HAVE_STRINGS_H) + check_include_files("stdlib.h" HAVE_STDLIB_H) + check_include_files("stdint.h" HAVE_STDINT_H) + check_include_files("inttypes.h" HAVE_INTTYPES_H) + check_include_files("memory.h" HAVE_MEMORY_H) + check_include_files("dlfcn.h" HAVE_DLFCN_H) - # Check some functions - check_function_exists( - "readlink" HAVE_READLINK CMAKE_REQUIRED_INCLUDES "unistd.h" - ) - check_function_exists( - "lstat" HAVE_READLINK CMAKE_REQUIRED_INCLUDES "sys/stat.h" - ) - check_function_exists( - "strnlen" HAVE_DECL_STRNLEN CMAKE_REQUIRED_INCLUDES "string.h" - ) + # Check some functions + check_function_exists( + "readlink" HAVE_READLINK CMAKE_REQUIRED_INCLUDES "unistd.h" + ) + check_function_exists( + "lstat" HAVE_READLINK CMAKE_REQUIRED_INCLUDES "sys/stat.h" + ) + check_function_exists( + "strnlen" HAVE_DECL_STRNLEN CMAKE_REQUIRED_INCLUDES "string.h" + ) - # Check unwind - check_include_files("unwind.h" UNWIND_HEADER_FOUND) - check_function_exists( - "_Unwind_Backtrace" UNWIND_FN_FOUND CMAKE_REQUIRED_INCLUDES - ) - if((${UNWIND_HEADER_FOUND}) AND (${UNWIND_FN_FOUND})) - set(sources "${sources};backtrace.c;simple.c") - else() - set(sources "${sources};nounwind.c") - set(BACKTRACE_SUPPORTED 0) - endif() + # Check unwind + check_include_files("unwind.h" UNWIND_HEADER_FOUND) + check_function_exists( + "_Unwind_Backtrace" UNWIND_FN_FOUND CMAKE_REQUIRED_INCLUDES + ) + if((${UNWIND_HEADER_FOUND}) AND (${UNWIND_FN_FOUND})) + set(sources "${sources};backtrace.c;simple.c") + else() + set(sources "${sources};nounwind.c") + set(BACKTRACE_SUPPORTED 0) + endif() - # Check UnwindGetIPInfo - set(oldFlags ${CMAKE_REQUIRED_FLAGS}) - set(CMAKE_REQUIRED_FLAGS "-Werror-implicit-function-declaration") - check_c_source_compiles(" - #include \"unwind.h\" + # Check UnwindGetIPInfo + set(oldFlags ${CMAKE_REQUIRED_FLAGS}) + set(CMAKE_REQUIRED_FLAGS "-Werror-implicit-function-declaration") + check_c_source_compiles(" + #include \"unwind.h\" - struct _Unwind_Context *context; - int ip_before_insn = 0; + struct _Unwind_Context *context; + int ip_before_insn = 0; - int main(void) { - return _Unwind_GetIPInfo (context, &ip_before_insn); - } - " HAVE_GETIPINFO) - set(CMAKE_REQUIRED_FLAGS ${oldFlags}) + int main(void) { + return _Unwind_GetIPInfo (context, &ip_before_insn); + } + " HAVE_GETIPINFO) + set(CMAKE_REQUIRED_FLAGS ${oldFlags}) - set(oldFlags ${CMAKE_REQUIRED_FLAGS}) - set(CMAKE_REQUIRED_FLAGS "-funwind-tables") - CHECK_C_COMPILER_FLAG("" unwind_tables_supported) - if(unwind_tables_supported) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -funwind-tables") - endif() - set(CMAKE_REQUIRED_FLAGS ${oldFlags}) + set(oldFlags ${CMAKE_REQUIRED_FLAGS}) + set(CMAKE_REQUIRED_FLAGS "-funwind-tables") + CHECK_C_COMPILER_FLAG("" unwind_tables_supported) + if(unwind_tables_supported) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -funwind-tables") + endif() + set(CMAKE_REQUIRED_FLAGS ${oldFlags}) - # Check threads - # TODO configure.ac checks hppa*-*-hpux* stuff, dunno what it is - check_c_source_compiles(" - int i; - int main(void) { - __sync_bool_compare_and_swap (&i, i, i); - __sync_lock_test_and_set (&i, 1); - __sync_lock_release (&i); - return 0; - } - " HAVE_SYNC_FUNCTIONS) - if(${HAVE_SYNC_FUNCTIONS}) - set(BACKTRACE_SUPPORTS_THREADS 1) - endif() + # Check threads + # TODO configure.ac checks hppa*-*-hpux* stuff, dunno what it is + check_c_source_compiles(" + int i; + int main(void) { + __sync_bool_compare_and_swap (&i, i, i); + __sync_lock_test_and_set (&i, 1); + __sync_lock_release (&i); + return 0; + } + " HAVE_SYNC_FUNCTIONS) + if(${HAVE_SYNC_FUNCTIONS}) + set(BACKTRACE_SUPPORTS_THREADS 1) + endif() - # Check __atomic support - check_c_source_compiles(" - int i; - int main(void) { - __atomic_load_n (&i, __ATOMIC_ACQUIRE); - __atomic_store_n (&i, 1, __ATOMIC_RELEASE); - return 0; - } - " HAVE_ATOMIC_FUNCTIONS) + # Check __atomic support + check_c_source_compiles(" + int i; + int main(void) { + __atomic_load_n (&i, __ATOMIC_ACQUIRE); + __atomic_store_n (&i, 1, __ATOMIC_RELEASE); + return 0; + } + " HAVE_ATOMIC_FUNCTIONS) - # The library needs to be able to read the executable itself. - # Determine executable format (elf32/elf64/pecoff) - if(("${CMAKE_EXECUTABLE_FORMAT}" STREQUAL "ELF")) - math(EXPR BACKTRACE_ELF_SIZE "${CMAKE_SIZEOF_VOID_P} * 8") - set(filetype "elf${BACKTRACE_ELF_SIZE}") - set(FORMAT_FILE "elf.c") - set(BACKTRACE_SUPPORTS_DATA 1) - else() - # TODO detect pecoff/xcoff in some way - especially on MinGW - message( - FATAL_ERROR "Unknown executable format: '${CMAKE_EXECUTABLE_FORMAT}'" - ) - endif() - message(STATUS "Executable format: ${filetype}") + # The library needs to be able to read the executable itself. + # Determine executable format (elf32/elf64/pecoff) + if(("${CMAKE_EXECUTABLE_FORMAT}" STREQUAL "ELF")) + math(EXPR BACKTRACE_ELF_SIZE "${CMAKE_SIZEOF_VOID_P} * 8") + set(filetype "elf${BACKTRACE_ELF_SIZE}") + set(FORMAT_FILE "elf.c") + set(BACKTRACE_SUPPORTS_DATA 1) + else() + # TODO detect pecoff/xcoff in some way - especially on MinGW + message( + FATAL_ERROR "Unknown executable format: '${CMAKE_EXECUTABLE_FORMAT}'" + ) + endif() + message(STATUS "Executable format: ${filetype}") - # mmap support - check_include_files("sys/mman.h" HAVE_SYS_MMAN_H) - if(HAVE_SYS_MMAN_H) - # TODO port from configure.ac: spu-*-*|*-*-msdosdjgpp - check_function_exists( - "mmap" have_mmap CMAKE_REQUIRED_INCLUDES "sys/mman.h" - ) - endif() - if(NOT have_mmap) - set(VIEW_FILE "read.c") - set(ALLOC_FILE "alloc.c") - else() - set(VIEW_FILE "mmapio.c") - check_c_source_compiles(" - #include - #if !defined(MAP_ANONYMOUS) && !defined(MAP_ANON) - #error no MAP_ANONYMOUS - #endif - " use_mmap_for_alloc) - if(use_mmap_for_alloc) - set(ALLOC_FILE "mmap.c") - else() - set(ALLOC_FILE "alloc.c") - endif() - if(${ALLOC_FILE} STREQUAL "alloc.c") - SET(BACKTRACE_USES_MALLOC 1) - else() - SET(BACKTRACE_USES_MALLOC 0) - endif() + # mmap support + check_include_files("sys/mman.h" HAVE_SYS_MMAN_H) + if(HAVE_SYS_MMAN_H) + # TODO port from configure.ac: spu-*-*|*-*-msdosdjgpp + check_function_exists( + "mmap" have_mmap CMAKE_REQUIRED_INCLUDES "sys/mman.h" + ) + endif() + if(NOT have_mmap) + set(VIEW_FILE "read.c") + set(ALLOC_FILE "alloc.c") + else() + set(VIEW_FILE "mmapio.c") + check_c_source_compiles(" + #include + #if !defined(MAP_ANONYMOUS) && !defined(MAP_ANON) + #error no MAP_ANONYMOUS + #endif + " use_mmap_for_alloc) + if(use_mmap_for_alloc) + set(ALLOC_FILE "mmap.c") + SET(BACKTRACE_USES_MALLOC 0) + else() + set(ALLOC_FILE "alloc.c") + SET(BACKTRACE_USES_MALLOC 1) + endif() - # Check for dl_iterate_phdr - check_include_files("link.h" HAVE_LINK_H) - if(HAVE_LINK_H) - # TODO port from configure.ac: *-*-solaris2.10* - check_function_exists( - "dl_iterate_phdr" HAVE_DL_ITERATE_PHDR - CMAKE_REQUIRED_INCLUDES "link.h" - ) - endif() + # Check for dl_iterate_phdr + check_include_files("link.h" HAVE_LINK_H) + if(HAVE_LINK_H) + # TODO port from configure.ac: *-*-solaris2.10* + check_function_exists( + "dl_iterate_phdr" HAVE_DL_ITERATE_PHDR + CMAKE_REQUIRED_INCLUDES "link.h" + ) + endif() - # Check for loadquery. - check_include_files("sys/ldr.h" HAVE_SYS_LDR_H) - check_function_exists( - "loadquery" HAVE_LOADQUERY CMAKE_REQUIRED_INCLUDES "sys/ldr.h" - ) - - # Check for fcntl function. - check_function_exists( - "fcntl" HAVE_FCNTL CMAKE_REQUIRED_INCLUDES "fcntl.h" - ) - - # Check for getexecname function. - check_function_exists( - "getexecname" HAVE_GETEXECNAME CMAKE_REQUIRED_INCLUDES "stdlib.h" - ) + # Check for loadquery. + check_include_files("sys/ldr.h" HAVE_SYS_LDR_H) + check_function_exists( + "loadquery" HAVE_LOADQUERY CMAKE_REQUIRED_INCLUDES "sys/ldr.h" + ) + + # Check for fcntl function. + check_function_exists( + "fcntl" HAVE_FCNTL CMAKE_REQUIRED_INCLUDES "fcntl.h" + ) + + # Check for getexecname function. + check_function_exists( + "getexecname" HAVE_GETEXECNAME CMAKE_REQUIRED_INCLUDES "stdlib.h" + ) - # Check for the clock_gettime function. - check_library_exists(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME) - if (HAVE_CLOCK_GETTIME) - set(CLOCK_GETTIME_LINK "-lrt") - else() - # might also be in libc - check_library_exists(c clock_gettime "" HAVE_CLOCK_GETTIME) - endif() + # Check for the clock_gettime function. + check_library_exists(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME) + if (HAVE_CLOCK_GETTIME) + set(CLOCK_GETTIME_LINK "-lrt") + else() + # might also be in libc + check_library_exists(c clock_gettime "" HAVE_CLOCK_GETTIME) + endif() - # Test whether the compiler supports the -pthread option - set(CMAKE_THREAD_PREFER_PTHREAD ON) - set(THREADS_PREFER_PTHREAD_FLAG ON) - find_package(Threads) - if(CMAKE_USE_PTHREADS_INIT) - set(HAVE_PTHREAD 1) - endif() - endif() - endif() + # Test whether the compiler supports the -pthread option + set(CMAKE_THREAD_PREFER_PTHREAD ON) + set(THREADS_PREFER_PTHREAD_FLAG ON) + find_package(Threads) + if(CMAKE_USE_PTHREADS_INIT) + set(HAVE_PTHREAD 1) + endif() + endif() + endif() else() - set(BACKTRACE_SUPPORTED 0) + set(BACKTRACE_SUPPORTED 0) endif() # Generate backtrace-supported.h and config.h @@ -263,12 +291,12 @@ endif() # let's not duplicate things unnecessarily. # config.h.in ain't parsed properly so we need slightly different version. configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/backtrace-supported.h.in - ${CMAKE_CURRENT_BINARY_DIR}/backtrace-supported.h + ${CMAKE_CURRENT_SOURCE_DIR}/backtrace-supported.h.in + ${CMAKE_CURRENT_BINARY_DIR}/backtrace-supported.h ) configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake - ${CMAKE_CURRENT_BINARY_DIR}/config.h + ${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake + ${CMAKE_CURRENT_BINARY_DIR}/config.h ) # Build commands @@ -276,10 +304,10 @@ add_library(backtrace ${sources} ${FORMAT_FILE} ${VIEW_FILE} ${ALLOC_FILE} ${exp include_directories(backtrace ${CMAKE_CURRENT_BINARY_DIR}) target_link_libraries(backtrace ${CLOCK_GETTIME_LINK}) if(CMAKE_USE_PTHREADS_INIT) - target_link_libraries(backtrace ${CMAKE_THREAD_LIBS_INIT}) + target_link_libraries(backtrace ${CMAKE_THREAD_LIBS_INIT}) endif() if(ZLIB_FOUND) - target_link_libraries(backtrace z) + target_link_libraries(backtrace z) endif() #install libbacktrace and header files @@ -289,14 +317,14 @@ set(INSTALL_CMAKE_DIR CMake) # Install CMake files install(TARGETS backtrace - DESTINATION ${INSTALL_LIB_DIR} - EXPORT libbacktrace-targets + DESTINATION ${INSTALL_LIB_DIR} + EXPORT libbacktrace-targets ) install(EXPORT libbacktrace-targets DESTINATION ${INSTALL_CMAKE_DIR}) install(FILES - ${CMAKE_SOURCE_DIR}/cmake/libbacktraceConfig.cmake - ${CMAKE_SOURCE_DIR}/cmake/libbacktraceConfigVersion.cmake - DESTINATION ${INSTALL_CMAKE_DIR} + ${CMAKE_SOURCE_DIR}/cmake/libbacktraceConfig.cmake + ${CMAKE_SOURCE_DIR}/cmake/libbacktraceConfigVersion.cmake + DESTINATION ${INSTALL_CMAKE_DIR} ) install(TARGETS backtrace DESTINATION "${INSTALL_LIB_DIR}") diff --git a/cmake/libbacktraceConfig.cmake b/cmake/libbacktraceConfig.cmake index 5083f1c..df3d1d9 100644 --- a/cmake/libbacktraceConfig.cmake +++ b/cmake/libbacktraceConfig.cmake @@ -1,3 +1,34 @@ +# libbacktraceConfig.cmake -- Backtrace configure script. +# Copyright (C) 2012-2018 Free Software Foundation, Inc. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# (1) Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# (2) 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. +# +# (3) The name of the author may not be used to +# endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. + # Usage: # #find_package(libbacktrace REQUIRED) @@ -11,4 +42,4 @@ set(libbacktrace_CONFIG_INCLUDED TRUE) get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) include(${SELF_DIR}/libbacktrace-targets.cmake) -get_filename_component(libbacktrace_INCLUDE_DIRS "${SELF_DIR}/.." ABSOLUTE) \ No newline at end of file +get_filename_component(libbacktrace_INCLUDE_DIRS "${SELF_DIR}/.." ABSOLUTE) diff --git a/cmake/libbacktraceConfigVersion.cmake b/cmake/libbacktraceConfigVersion.cmake index e9aac3f..48e81c3 100644 --- a/cmake/libbacktraceConfigVersion.cmake +++ b/cmake/libbacktraceConfigVersion.cmake @@ -1,3 +1,34 @@ +# libbacktraceConfigVersion.cmake -- Backtrace configure script. +# Copyright (C) 2012-2018 Free Software Foundation, Inc. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# (1) Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# (2) 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. +# +# (3) The name of the author may not be used to +# endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. + set(PACKAGE_VERSION "1.0.0") if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) @@ -18,4 +49,4 @@ else() if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) set(PACKAGE_VERSION_EXACT TRUE) endif() -endif() \ No newline at end of file +endif()