Static libstdcxx and python (#139)

Support python + static libstdc++
This commit is contained in:
Jonathan R. Madsen authored and GitHub committed 2022-08-28 03:56:13 -05:00
1 parent 0dd8f52292
commit a1dcd1bc4b
11 files changed
+127 -57

No files matched your search

+27 -7
View File
@@ -25,11 +25,16 @@ omnitrace_add_option(OMNITRACE_BUILD_STATIC_LIBGCC
"Build with -static-libgcc if possible" OFF)
omnitrace_add_option(OMNITRACE_BUILD_STATIC_LIBSTDCXX
"Build with -static-libstdc++ if possible" OFF)
omnitrace_add_option(OMNITRACE_BUILD_STACK_PROTECTOR "Build with -fstack-protector" ON)
omnitrace_add_interface_library(omnitrace-static-libgcc
"Link to static version of libgcc")
omnitrace_add_interface_library(omnitrace-static-libstdcxx
"Link to static version of libstdc++")
omnitrace_add_interface_library(omnitrace-static-libgcc-optional
"Link to static version of libgcc")
omnitrace_add_interface_library(omnitrace-static-libstdcxx-optional
"Link to static version of libstdc++")
target_compile_definitions(omnitrace-compile-options INTERFACE $<$<CONFIG:DEBUG>:DEBUG>)
@@ -194,6 +199,18 @@ if(OMNITRACE_USE_COMPILE_TIMING)
target_link_libraries(omnitrace-compile-options INTERFACE omnitrace-compile-timing)
endif()
# ----------------------------------------------------------------------------------------#
# fstack-protector
#
omnitrace_add_interface_library(omnitrace-stack-protector
"Adds stack-protector compiler flags")
add_target_flag_if_avail(omnitrace-stack-protector "-fstack-protector-strong"
"-Wstack-protector")
if(OMNITRACE_BUILD_STACK_PROTECTOR)
target_link_libraries(omnitrace-compile-options INTERFACE omnitrace-stack-protector)
endif()
# ----------------------------------------------------------------------------------------#
# developer build flags
#
@@ -281,13 +298,6 @@ else()
set(OMNITRACE_USE_SANITIZER OFF)
endif()
if(MSVC)
# VTune is much more helpful when debug information is included in the generated
# release code.
add_flag_if_avail("/Zi")
add_flag_if_avail("/DEBUG")
endif()
# ----------------------------------------------------------------------------------------#
# static lib flags
#
@@ -308,6 +318,16 @@ target_link_options(
omnitrace-static-libstdcxx INTERFACE
$<$<COMPILE_LANGUAGE:CXX>:$<$<CXX_COMPILER_ID:GNU,Clang>:-static-libstdc++>>)
if(OMNITRACE_BUILD_STATIC_LIBGCC)
target_link_libraries(omnitrace-static-libgcc-optional
INTERFACE omnitrace-static-libgcc)
endif()
if(OMNITRACE_BUILD_STATIC_LIBSTDCXX)
target_link_libraries(omnitrace-static-libstdcxx-optional
INTERFACE omnitrace-static-libstdcxx)
endif()
# ----------------------------------------------------------------------------------------#
# user customization
#
+46 -14
View File
@@ -41,8 +41,21 @@ find_program(OMNITRACE_CLANG_FORMAT_EXE NAMES clang-format-11 clang-format-mp-11
clang-format)
find_program(OMNITRACE_CMAKE_FORMAT_EXE NAMES cmake-format)
find_program(OMNITRACE_BLACK_FORMAT_EXE NAMES black)
if(OMNITRACE_CLANG_FORMAT_EXE)
add_custom_target(format-omnitrace)
if(NOT TARGET format)
add_custom_target(format)
endif()
foreach(_TYPE source python cmake)
if(NOT TARGET format-${_TYPE})
add_custom_target(format-${_TYPE})
endif()
endforeach()
if(OMNITRACE_CLANG_FORMAT_EXE
OR OMNITRACE_BLACK_FORMAT_EXE
OR OMNITRACE_CMAKE_FORMAT_EXE)
file(GLOB_RECURSE sources ${PROJECT_SOURCE_DIR}/source/*.cpp)
file(GLOB_RECURSE headers ${PROJECT_SOURCE_DIR}/source/*.hpp
${PROJECT_SOURCE_DIR}/source/*.hpp.in ${PROJECT_SOURCE_DIR}/source/*.h
@@ -63,16 +76,25 @@ if(OMNITRACE_CLANG_FORMAT_EXE)
list(REMOVE_ITEM examples ${external})
list(REMOVE_ITEM cmake_files ${external})
endif()
add_custom_target(
format-omnitrace-source
${OMNITRACE_CLANG_FORMAT_EXE} -i ${sources} ${headers} ${examples}
COMMENT "[omnitrace] Running C++ formatter ${OMNITRACE_CLANG_FORMAT_EXE}...")
add_custom_target(format-omnitrace)
add_dependencies(format-omnitrace format-omnitrace-source)
if(NOT TARGET format)
add_custom_target(format)
if(OMNITRACE_CLANG_FORMAT_EXE)
add_custom_target(
format-omnitrace-source
${OMNITRACE_CLANG_FORMAT_EXE} -i ${sources} ${headers} ${examples}
COMMENT "[omnitrace] Running C++ formatter ${OMNITRACE_CLANG_FORMAT_EXE}...")
endif()
add_dependencies(format format-omnitrace)
if(OMNITRACE_BLACK_FORMAT_EXE)
add_custom_target(
format-omnitrace-python
${OMNITRACE_BLACK_FORMAT_EXE} ${PROJECT_SOURCE_DIR}
COMMENT
"[omnitrace] Running Python formatter ${OMNITRACE_BLACK_FORMAT_EXE}...")
if(NOT TARGET format-python)
add_custom_target(format-python)
endif()
endif()
if(OMNITRACE_CMAKE_FORMAT_EXE)
add_custom_target(
format-omnitrace-cmake
@@ -82,10 +104,20 @@ if(OMNITRACE_CLANG_FORMAT_EXE)
if(NOT TARGET format-cmake)
add_custom_target(format-cmake)
endif()
add_dependencies(format-cmake format-omnitrace-cmake)
endif()
foreach(_TYPE source python cmake)
if(TARGET format-omnitrace-${_TYPE})
add_dependencies(format-omnitrace format-omnitrace-${_TYPE})
add_dependencies(format-${_TYPE} format-omnitrace-${_TYPE})
endif()
endforeach()
foreach(_TYPE source python)
if(TARGET format-omnitrace-${_TYPE})
add_dependencies(format format-omnitrace-${_TYPE})
endif()
endforeach()
else()
message(
AUTHOR_WARNING
"clang-format could not be found. format build target not available.")
message(STATUS "clang-format could not be found. format build target not available.")
endif()
+5
View File
@@ -505,6 +505,11 @@ endif()
target_compile_definitions(omnitrace-timemory-config INTERFACE TIMEMORY_PAPI_ARRAY_SIZE=16
TIMEMORY_USE_ROOFLINE=0)
if(OMNITRACE_BUILD_STACK_PROTECTOR)
add_target_flag_if_avail(omnitrace-timemory-config "-fstack-protector-strong"
"-Wstack-protector")
endif()
set(TIMEMORY_EXTERNAL_INTERFACE_LIBRARY
omnitrace-timemory-config
CACHE STRING "timemory configuration interface library")