feat(third_party): add oatpp,googltest,benchmark
All checks were successful
sm-rpc / build (Debug, aarch64-linux-gnu) (push) Successful in 1m7s
sm-rpc / build (Debug, arm-linux-gnueabihf) (push) Successful in 1m15s
sm-rpc / build (Debug, host.gcc) (push) Successful in 1m4s
sm-rpc / build (Debug, mipsel-linux-gnu) (push) Successful in 1m16s
sm-rpc / build (Release, aarch64-linux-gnu) (push) Successful in 1m34s
sm-rpc / build (Release, arm-linux-gnueabihf) (push) Successful in 1m33s
sm-rpc / build (Release, host.gcc) (push) Successful in 1m23s
sm-rpc / build (Release, mipsel-linux-gnu) (push) Successful in 1m30s
All checks were successful
sm-rpc / build (Debug, aarch64-linux-gnu) (push) Successful in 1m7s
sm-rpc / build (Debug, arm-linux-gnueabihf) (push) Successful in 1m15s
sm-rpc / build (Debug, host.gcc) (push) Successful in 1m4s
sm-rpc / build (Debug, mipsel-linux-gnu) (push) Successful in 1m16s
sm-rpc / build (Release, aarch64-linux-gnu) (push) Successful in 1m34s
sm-rpc / build (Release, arm-linux-gnueabihf) (push) Successful in 1m33s
sm-rpc / build (Release, host.gcc) (push) Successful in 1m23s
sm-rpc / build (Release, mipsel-linux-gnu) (push) Successful in 1m30s
This commit is contained in:
330
third_party/oatpp/cmake/compiler-flags.cmake
vendored
Normal file
330
third_party/oatpp/cmake/compiler-flags.cmake
vendored
Normal file
@@ -0,0 +1,330 @@
|
||||
###################################################################################################
|
||||
## INCLUDES #######################################################################################
|
||||
###################################################################################################
|
||||
|
||||
include(CheckCXXCompilerFlag)
|
||||
|
||||
|
||||
###################################################################################################
|
||||
## FUNCTIONS ######################################################################################
|
||||
###################################################################################################
|
||||
|
||||
#
|
||||
# Add compiler flags without test (assume they are supported)
|
||||
#
|
||||
|
||||
function(add_cxx_compiler_flags_no_test var)
|
||||
foreach(flag ${ARGN})
|
||||
set(${var} "${${var}} ${flag}")
|
||||
endforeach()
|
||||
set(${var} "${${var}}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
|
||||
#
|
||||
# Add compiler flags with test (do not assume they are supported)
|
||||
#
|
||||
|
||||
function(add_cxx_compiler_flags var)
|
||||
foreach(flag ${ARGN})
|
||||
string(REGEX REPLACE "[^a-zA-Z0-9]+" "_" flag_var "CXXFLAG_${flag}")
|
||||
check_cxx_compiler_flag("${flag}" ${flag_var})
|
||||
if(${flag_var})
|
||||
set(${var} "${${var}} ${flag}")
|
||||
endif()
|
||||
endforeach()
|
||||
set(${var} "${${var}}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
|
||||
#
|
||||
# Add compiler flags
|
||||
#
|
||||
|
||||
function(add_compiler_flags version)
|
||||
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL ${version})
|
||||
foreach(flag ${ARGN})
|
||||
add_cxx_compiler_flags_no_test(CMAKE_CXX_FLAGS ${flag})
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" PARENT_SCOPE)
|
||||
endforeach()
|
||||
else (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL ${version})
|
||||
foreach(flag ${ARGN})
|
||||
add_cxx_compiler_flags(CMAKE_CXX_FLAGS ${flag})
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" PARENT_SCOPE)
|
||||
endforeach()
|
||||
endif (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL ${version})
|
||||
endfunction()
|
||||
|
||||
|
||||
#
|
||||
# Remove compiler flags
|
||||
#
|
||||
|
||||
function(remove_any_compiler_flags var)
|
||||
foreach(flag ${ARGN})
|
||||
string(REPLACE "${flag}" "" ${var} "${${var}}")
|
||||
string(REGEX REPLACE "[ \t]+" " " ${var} "${${var}}")
|
||||
endforeach()
|
||||
set(${var} "${${var}}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(remove_compiler_flags)
|
||||
foreach(flag ${ARGN})
|
||||
remove_any_compiler_flags(CMAKE_CXX_FLAGS "${flag}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" PARENT_SCOPE)
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
|
||||
#
|
||||
# Save and Restore compiler flags
|
||||
#
|
||||
|
||||
function(save_compiler_flags)
|
||||
set(CMAKE_CXX_FLAGS_SAVED "${CMAKE_CXX_FLAGS}" CACHE STRING "Saved compiler C++ flags" FORCE)
|
||||
endfunction()
|
||||
|
||||
function(restore_compiler_flags)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_SAVED}" )
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
|
||||
###################################################################################################
|
||||
## COMPILER FLAGS #################################################################################
|
||||
###################################################################################################
|
||||
|
||||
string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER)
|
||||
|
||||
#
|
||||
# Generic flags
|
||||
#
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES GNU)
|
||||
add_compiler_flags(4.6 "-Wall")
|
||||
add_compiler_flags(4.6 "-Wextra")
|
||||
endif (CMAKE_CXX_COMPILER_ID MATCHES GNU)
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
add_compiler_flags(10 "-Weverything")
|
||||
endif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
|
||||
|
||||
#
|
||||
# Preserve debug information flags
|
||||
#
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES GNU)
|
||||
add_compiler_flags(4.6 "-g3")
|
||||
endif (CMAKE_CXX_COMPILER_ID MATCHES GNU)
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
add_compiler_flags(10 "-g3")
|
||||
endif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
|
||||
|
||||
#
|
||||
# C/C++ Warning Flags
|
||||
# See https://github.com/vadz/gcc-warnings-tools for gcc flags and versions
|
||||
#
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES GNU)
|
||||
add_compiler_flags(4.6 "-Wcast-align")
|
||||
add_compiler_flags(4.6 "-Wconversion")
|
||||
add_compiler_flags(4.6 "-Wdouble-promotion")
|
||||
add_compiler_flags(4.6 "-Winvalid-pch")
|
||||
add_compiler_flags(4.6 "-Wmissing-declarations")
|
||||
add_compiler_flags(4.6 "-Wmissing-format-attribute")
|
||||
add_compiler_flags(4.6 "-Wmissing-include-dirs")
|
||||
add_compiler_flags(4.6 "-Wpointer-arith")
|
||||
add_compiler_flags(4.6 "-Wredundant-decls")
|
||||
add_compiler_flags(4.6 "-Wshadow")
|
||||
add_compiler_flags(4.6 "-Wsign-conversion")
|
||||
#add_compiler_flags(4.6 "-Wsuggest-attribute=const")
|
||||
add_compiler_flags(4.6 "-Wsuggest-attribute=noreturn")
|
||||
#add_compiler_flags(4.6 "-Wsuggest-attribute=pure")
|
||||
add_compiler_flags(4.6 "-Wswitch-default")
|
||||
add_compiler_flags(4.6 "-Wswitch-enum")
|
||||
add_compiler_flags(4.6 "-Wtype-limits")
|
||||
add_compiler_flags(4.6 "-Wundef")
|
||||
add_compiler_flags(4.6 "-Wuninitialized")
|
||||
add_compiler_flags(4.6 "-Wunknown-pragmas")
|
||||
add_compiler_flags(4.6 "-Wunsafe-loop-optimizations")
|
||||
add_compiler_flags(4.6 "-Wunused-but-set-parameter")
|
||||
add_compiler_flags(4.6 "-Wunused-but-set-variable")
|
||||
add_compiler_flags(4.6 "-Wunused-function")
|
||||
add_compiler_flags(4.6 "-Wunused")
|
||||
add_compiler_flags(4.6 "-Wunused-label")
|
||||
add_compiler_flags(4.6 "-Wunused-macros")
|
||||
#add_compiler_flags(4.6 "-Wunused-parameter")
|
||||
add_compiler_flags(4.6 "-Wunused-result")
|
||||
add_compiler_flags(4.6 "-Wunused-value")
|
||||
add_compiler_flags(4.6 "-Wunused-variable")
|
||||
|
||||
add_compiler_flags(4.7 "-Wunused-local-typedefs")
|
||||
|
||||
add_compiler_flags(4.8 "-Wformat=2")
|
||||
add_compiler_flags(4.8 "-Wsuggest-attribute=format")
|
||||
|
||||
add_compiler_flags(5.1 "-Wformat-signedness")
|
||||
#add_compiler_flags(5.1 "-Wsuggest-final-methods")
|
||||
#add_compiler_flags(5.1 "-Wsuggest-final-types")
|
||||
|
||||
add_compiler_flags(6.1 "-Wduplicated-cond")
|
||||
add_compiler_flags(6.1 "-Wlogical-op")
|
||||
add_compiler_flags(6.1 "-Wnull-dereference")
|
||||
|
||||
add_compiler_flags(7.1 "-Wduplicated-branches")
|
||||
add_compiler_flags(7.1 "-Wformat-overflow=2")
|
||||
add_compiler_flags(7.1 "-Wformat-truncation=2")
|
||||
|
||||
#add_compiler_flags(8.1 "-Wcast-align=strict")
|
||||
add_compiler_flags(8.1 "-Wsuggest-attribute=cold")
|
||||
add_compiler_flags(8.1 "-Wsuggest-attribute=malloc")
|
||||
|
||||
add_compiler_flags(10.1 "-Warith-conversion")
|
||||
|
||||
add_compiler_flags(12.1 "-ftrivial-auto-var-init=zero")
|
||||
add_compiler_flags(12.1 "-Warray-compare")
|
||||
add_compiler_flags(12.1 "-Wbidi-chars=unpaired,ucn")
|
||||
add_compiler_flags(12.1 "-Winfinite-recursion")
|
||||
add_compiler_flags(12.1 "-Wopenacc-parallelism")
|
||||
add_compiler_flags(12.1 "-Wtrivial-auto-var-init")
|
||||
endif (CMAKE_CXX_COMPILER_ID MATCHES GNU)
|
||||
|
||||
|
||||
#
|
||||
# C++ Warning Flags
|
||||
# See https://github.com/vadz/gcc-warnings-tools for gcc flags and versions
|
||||
#
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES GNU)
|
||||
add_compiler_flags(4.6 "-Wctor-dtor-privacy")
|
||||
add_compiler_flags(4.6 "-Wnoexcept")
|
||||
add_compiler_flags(4.6 "-Wold-style-cast")
|
||||
add_compiler_flags(4.6 "-Woverloaded-virtual")
|
||||
add_compiler_flags(4.6 "-Wsign-promo")
|
||||
add_compiler_flags(4.6 "-Wstrict-null-sentinel")
|
||||
|
||||
add_compiler_flags(4.7 "-Wzero-as-null-pointer-constant")
|
||||
|
||||
add_compiler_flags(4.8 "-Wuseless-cast")
|
||||
|
||||
add_compiler_flags(4.9 "-Wconditionally-supported")
|
||||
|
||||
add_compiler_flags(5.1 "-Wsuggest-override")
|
||||
|
||||
add_compiler_flags(7.1 "-Wnoexcept-type")
|
||||
|
||||
add_compiler_flags(8.1 "-Wextra-semi")
|
||||
|
||||
add_compiler_flags(10.1 "-Wcomma-subscript")
|
||||
add_compiler_flags(10.1 "-Wmismatched-tags")
|
||||
add_compiler_flags(10.1 "-Wredundant-tags")
|
||||
add_compiler_flags(10.1 "-Wvolatile")
|
||||
|
||||
add_compiler_flags(11.1 "-Wctad-maybe-unsupported")
|
||||
add_compiler_flags(11.1 "-Wdeprecated-enum-enum-conversion")
|
||||
add_compiler_flags(11.1 "-Wdeprecated-enum-float-conversion")
|
||||
add_compiler_flags(11.1 "-Winvalid-imported-macros")
|
||||
add_compiler_flags(11.1 "-Wrange-loop-construct")
|
||||
endif (CMAKE_CXX_COMPILER_ID MATCHES GNU)
|
||||
|
||||
|
||||
#
|
||||
# Allow the linker to remove unused data and functions
|
||||
#
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES GNU)
|
||||
add_compiler_flags(4.6 "-fdata-sections")
|
||||
add_compiler_flags(4.6 "-ffunction-sections")
|
||||
add_compiler_flags(4.6 "-fno-common")
|
||||
add_compiler_flags(4.6 "-Wl,--gc-sections")
|
||||
endif (CMAKE_CXX_COMPILER_ID MATCHES GNU)
|
||||
|
||||
|
||||
#
|
||||
# Hardening flags
|
||||
# See https://developers.redhat.com/blog/2018/03/21/compiler-and-linker-flags-gcc
|
||||
#
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES GNU)
|
||||
IF (NOT CMAKE_BUILD_TYPE_LOWER STREQUAL "debug")
|
||||
add_cxx_compiler_flags_no_test(CMAKE_CXX_FLAGS "-D_FORTIFY_SOURCE=2")
|
||||
ENDIF (NOT CMAKE_BUILD_TYPE_LOWER STREQUAL "debug")
|
||||
add_cxx_compiler_flags_no_test(CMAKE_CXX_FLAGS "-D_GLIBCXX_ASSERTIONS")
|
||||
add_compiler_flags(4.6 "-fasynchronous-unwind-tables")
|
||||
add_compiler_flags(4.6 "-fexceptions")
|
||||
add_compiler_flags(8.1 "-fstack-clash-protection")
|
||||
add_compiler_flags(4.6 "-fstack-protector-strong")
|
||||
add_compiler_flags(4.6 "-grecord-gcc-switches")
|
||||
# Issue 872: https://github.com/oatpp/oatpp/issues/872
|
||||
# -fcf-protection is supported only on x86 GNU/Linux per this gcc doc:
|
||||
# https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html#index-fcf-protection
|
||||
if ((CMAKE_SYSTEM_NAME STREQUAL "Linux") AND (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)"))
|
||||
add_compiler_flags(8.1 "-fcf-protection")
|
||||
endif ()
|
||||
add_compiler_flags(4.6 "-pipe")
|
||||
add_compiler_flags(4.6 "-Werror=format-security")
|
||||
add_compiler_flags(4.6 "-Wno-format-nonliteral")
|
||||
add_compiler_flags(4.6 "-fPIE")
|
||||
add_compiler_flags(4.6 "-Wl,-z,defs")
|
||||
add_compiler_flags(4.6 "-Wl,-z,now")
|
||||
add_compiler_flags(4.6 "-Wl,-z,relro")
|
||||
endif (CMAKE_CXX_COMPILER_ID MATCHES GNU)
|
||||
|
||||
|
||||
#
|
||||
# Profiling and Debugging
|
||||
# See https://fedoraproject.org/wiki/Changes/fno-omit-frame-pointer
|
||||
#
|
||||
#if (CMAKE_CXX_COMPILER_ID MATCHES GNU)
|
||||
# add_compiler_flags(4.6 "-fno-omit-frame-pointer")
|
||||
#endif (CMAKE_CXX_COMPILER_ID MATCHES GNU)
|
||||
|
||||
|
||||
#
|
||||
# Disable some warnings
|
||||
#
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES GNU)
|
||||
add_compiler_flags(4.6 "-Wno-unused-parameter")
|
||||
|
||||
add_compiler_flags(9.1 "-Wno-pessimizing-move")
|
||||
endif (CMAKE_CXX_COMPILER_ID MATCHES GNU)
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
add_compiler_flags(14 "-Wno-c++14-attribute-extensions")
|
||||
add_compiler_flags(10 "-Wno-c++14-extensions")
|
||||
add_compiler_flags(10 "-Wno-c++98-compat")
|
||||
add_compiler_flags(10 "-Wno-c++98-compat-pedantic")
|
||||
add_compiler_flags(10 "-Wno-covered-switch-default")
|
||||
add_compiler_flags(10 "-Wno-delete-non-abstract-non-virtual-dtor")
|
||||
add_compiler_flags(10 "-Wno-deprecated-copy-dtor")
|
||||
add_compiler_flags(14 "-Wno-deprecated-copy-with-user-provided-dtor")
|
||||
add_compiler_flags(10 "-Wno-documentation")
|
||||
add_compiler_flags(10 "-Wno-documentation-unknown-command")
|
||||
add_compiler_flags(10 "-Wno-exit-time-destructors")
|
||||
add_compiler_flags(10 "-Wno-format-nonliteral")
|
||||
add_compiler_flags(10 "-Wno-global-constructors")
|
||||
add_compiler_flags(10 "-Wno-gnu-zero-variadic-macro-arguments")
|
||||
add_compiler_flags(10 "-Wno-implicit-int-conversion")
|
||||
add_compiler_flags(10 "-Wno-non-virtual-dtor")
|
||||
add_compiler_flags(10 "-Wno-padded")
|
||||
add_compiler_flags(10 "-Wno-pessimizing-move")
|
||||
add_compiler_flags(99 "-Wno-return-std-move-in-c++11")
|
||||
add_compiler_flags(10 "-Wno-reserved-id-macro")
|
||||
add_compiler_flags(14 "-Wno-reserved-identifier")
|
||||
add_compiler_flags(10 "-Wno-string-conversion")
|
||||
add_compiler_flags(14 "-Wno-suggest-destructor-override")
|
||||
add_compiler_flags(10 "-Wno-unknown-warning-option")
|
||||
add_compiler_flags(10 "-Wno-unneeded-member-function")
|
||||
add_compiler_flags(10 "-Wno-unreachable-code-return")
|
||||
add_compiler_flags(10 "-Wno-unsafe-buffer-usage")
|
||||
add_compiler_flags(10 "-Wno-unused-member-function")
|
||||
add_compiler_flags(10 "-Wno-unused-parameter")
|
||||
add_compiler_flags(10 "-Wno-unused-template")
|
||||
add_compiler_flags(10 "-Wno-weak-vtables")
|
||||
endif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
|
||||
|
||||
#
|
||||
# Sanitize flags
|
||||
#
|
||||
#if (CMAKE_CXX_COMPILER_ID MATCHES GNU)
|
||||
# add_compiler_flags(4.6 "-fsanitize=address")
|
||||
# add_compiler_flags(4.6 "-fsanitize=thread")
|
||||
#endif (CMAKE_CXX_COMPILER_ID MATCHES GNU)
|
11
third_party/oatpp/cmake/module-config.cmake.in
vendored
Normal file
11
third_party/oatpp/cmake/module-config.cmake.in
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
@PACKAGE_INIT@
|
||||
|
||||
if(NOT TARGET oatpp::@OATPP_MODULE_NAME@)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@OATPP_MODULE_NAME@Targets.cmake")
|
||||
endif()
|
||||
|
||||
set_and_check(@OATPP_MODULE_NAME@_INCLUDE_DIRS "${PACKAGE_PREFIX_DIR}/include/oatpp-@OATPP_MODULE_VERSION@/@OATPP_MODULE_NAME@/")
|
||||
set_and_check(@OATPP_MODULE_NAME@_LIBRARIES_DIRS "${PACKAGE_PREFIX_DIR}/@OATPP_MODULE_LIBDIR@/oatpp-@OATPP_MODULE_VERSION@/")
|
||||
|
||||
set(@OATPP_MODULE_NAME@_LIBRARIES @OATPP_MODULE_LIBRARIES@)
|
||||
set(OATPP_BASE_DIR "${PACKAGE_PREFIX_DIR}/include/oatpp-@OATPP_MODULE_VERSION@/")
|
118
third_party/oatpp/cmake/module-install.cmake
vendored
Normal file
118
third_party/oatpp/cmake/module-install.cmake
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
#######################################################################################
|
||||
## Set module properties
|
||||
## all oatpp modules should have the same installation procedure
|
||||
##
|
||||
## installation tree:
|
||||
##
|
||||
## prefix/
|
||||
## |
|
||||
## |- include/oatpp-<version>/<module-name>
|
||||
## - lib/
|
||||
## |
|
||||
## |- cmake/<module-name>-<version>/
|
||||
## | |
|
||||
## | |- <module-name>Config.cmake
|
||||
## | - <module-name>ConfigVersion.cmake
|
||||
## |
|
||||
## - oatpp-<version>/
|
||||
## |
|
||||
## |- lib1.a
|
||||
## |- lib2.a
|
||||
## - ...
|
||||
##
|
||||
######################################################################################
|
||||
|
||||
message("\n############################################################################")
|
||||
message("## oatpp-module-install.cmake\n")
|
||||
|
||||
message("OATPP_THIS_MODULE_NAME=${OATPP_THIS_MODULE_NAME}")
|
||||
message("OATPP_THIS_MODULE_VERSION=${OATPP_THIS_MODULE_VERSION}")
|
||||
message("OATPP_THIS_MODULE_LIBRARIES=${OATPP_THIS_MODULE_LIBRARIES}")
|
||||
message("OATPP_THIS_MODULE_TARGETS=${OATPP_THIS_MODULE_TARGETS}")
|
||||
message("OATPP_THIS_MODULE_DIRECTORIES=${OATPP_THIS_MODULE_DIRECTORIES}")
|
||||
|
||||
message("\n############################################################################\n")
|
||||
|
||||
#######################################################################################
|
||||
## Set cache variables to configure module-config.cmake.in template
|
||||
## via call to configure_package_config_file
|
||||
|
||||
include(GNUInstallDirs)
|
||||
|
||||
set(OATPP_MODULE_NAME ${OATPP_THIS_MODULE_NAME} CACHE STRING "oatpp module name")
|
||||
set(OATPP_MODULE_VERSION "${OATPP_THIS_MODULE_VERSION}" CACHE STRING "oatpp module version")
|
||||
set(OATPP_MODULE_LIBRARIES
|
||||
"${OATPP_THIS_MODULE_LIBRARIES}" ## list libraries to find when find_package is called
|
||||
CACHE INTERNAL "oatpp module libraries"
|
||||
)
|
||||
set(OATPP_MODULE_LIBDIR ${CMAKE_INSTALL_LIBDIR} CACHE STRING "lib folder name")
|
||||
|
||||
#######################################################################################
|
||||
## calc directories to install (relative to this script)
|
||||
## dirs should be in ( relative ../src/<dirs>)
|
||||
|
||||
foreach(CURR_DIR ${OATPP_THIS_MODULE_DIRECTORIES})
|
||||
list(APPEND OATPP_DIRS_TO_INSTALL ${CMAKE_CURRENT_LIST_DIR}/../src/${CURR_DIR})
|
||||
endforeach()
|
||||
|
||||
#######################################################################################
|
||||
|
||||
install(
|
||||
TARGETS ${OATPP_THIS_MODULE_TARGETS}
|
||||
EXPORT "${OATPP_MODULE_NAME}Targets"
|
||||
ARCHIVE
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/oatpp-${OATPP_MODULE_VERSION}"
|
||||
COMPONENT Devel
|
||||
LIBRARY
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/oatpp-${OATPP_MODULE_VERSION}"
|
||||
COMPONENT Library
|
||||
RUNTIME
|
||||
DESTINATION "${CMAKE_INSTALL_BINDIR}/oatpp-${OATPP_MODULE_VERSION}"
|
||||
COMPONENT Library
|
||||
INCLUDES
|
||||
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/oatpp-${OATPP_MODULE_VERSION}/${OATPP_MODULE_NAME}"
|
||||
)
|
||||
|
||||
install(DIRECTORY ${OATPP_DIRS_TO_INSTALL}
|
||||
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/oatpp-${OATPP_MODULE_VERSION}/${OATPP_MODULE_NAME}"
|
||||
COMPONENT Devel
|
||||
FILES_MATCHING PATTERN "*.hpp"
|
||||
)
|
||||
|
||||
install(EXPORT "${OATPP_MODULE_NAME}Targets"
|
||||
FILE "${OATPP_MODULE_NAME}Targets.cmake"
|
||||
NAMESPACE oatpp::
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${OATPP_MODULE_NAME}-${OATPP_MODULE_VERSION}"
|
||||
COMPONENT Devel
|
||||
)
|
||||
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
write_basic_package_version_file("${OATPP_MODULE_NAME}ConfigVersion.cmake"
|
||||
VERSION ${OATPP_MODULE_VERSION}
|
||||
COMPATIBILITY ExactVersion ## Use exact version matching.
|
||||
)
|
||||
|
||||
## Take module-config.cmake.in file in this direcory as a template
|
||||
|
||||
configure_package_config_file(
|
||||
"${CMAKE_CURRENT_LIST_DIR}/module-config.cmake.in"
|
||||
"${OATPP_MODULE_NAME}Config.cmake"
|
||||
INSTALL_DESTINATION
|
||||
"${CMAKE_INSTALL_LIBDIR}/cmake/${OATPP_MODULE_NAME}-${OATPP_MODULE_VERSION}"
|
||||
PATH_VARS
|
||||
OATPP_MODULE_NAME
|
||||
OATPP_MODULE_VERSION
|
||||
OATPP_MODULE_LIBRARIES
|
||||
OATPP_MODULE_LIBDIR
|
||||
NO_CHECK_REQUIRED_COMPONENTS_MACRO
|
||||
)
|
||||
|
||||
install(
|
||||
FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${OATPP_MODULE_NAME}Config.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${OATPP_MODULE_NAME}ConfigVersion.cmake"
|
||||
DESTINATION
|
||||
"${CMAKE_INSTALL_LIBDIR}/cmake/${OATPP_MODULE_NAME}-${OATPP_MODULE_VERSION}"
|
||||
COMPONENT Devel
|
||||
)
|
36
third_party/oatpp/cmake/msvc-runtime.cmake
vendored
Normal file
36
third_party/oatpp/cmake/msvc-runtime.cmake
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
macro(configure_msvc_runtime)
|
||||
if(MSVC)
|
||||
# Set compiler options.
|
||||
set(variables
|
||||
CMAKE_C_FLAGS
|
||||
CMAKE_C_FLAGS_DEBUG
|
||||
CMAKE_C_FLAGS_MINSIZEREL
|
||||
CMAKE_C_FLAGS_RELEASE
|
||||
CMAKE_C_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_CXX_FLAGS
|
||||
CMAKE_CXX_FLAGS_DEBUG
|
||||
CMAKE_CXX_FLAGS_MINSIZEREL
|
||||
CMAKE_CXX_FLAGS_RELEASE
|
||||
CMAKE_CXX_FLAGS_RELWITHDEBINFO)
|
||||
|
||||
if(OATPP_MSVC_LINK_STATIC_RUNTIME)
|
||||
message(STATUS "MSVC: using statically-linked runtime (/MT and /MTd).")
|
||||
foreach(variable ${variables})
|
||||
if(${variable} MATCHES "/MD")
|
||||
string(REGEX REPLACE "/MD" "/MT" ${variable} "${${variable}}")
|
||||
endif()
|
||||
endforeach()
|
||||
else()
|
||||
message(STATUS "MSVC: using dynamically-linked runtime (/MD and /MDd).")
|
||||
foreach(variable ${variables})
|
||||
if(${variable} MATCHES "/MT")
|
||||
string(REGEX REPLACE "/MT" "/MD" ${variable} "${${variable}}")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
foreach(variable ${variables})
|
||||
set(${variable} "${${variable}}" CACHE STRING "MSVC_${variable}" FORCE)
|
||||
endforeach()
|
||||
endif()
|
||||
endmacro(configure_msvc_runtime)
|
131
third_party/oatpp/cmake/project.cmake
vendored
Normal file
131
third_party/oatpp/cmake/project.cmake
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
#[[
|
||||
Set default source groups.
|
||||
|
||||
set_target_source_groups(<target>
|
||||
[STRIP_PREFIX <strip-prefix>]
|
||||
[STRIP_SOURCE_PREFIX <strip-source-prefix>]
|
||||
[STRIP_BINARY_PREFIX <strip-binary-prefix>]
|
||||
[EXTRA_BINARY_DIRECTORY <extra-binary-dir>])
|
||||
|
||||
Create source groups "Header Files", "Header Templates", "Source Files", "Source Templates",
|
||||
"Generated Files" for the source files of the target <target>. Only files inside the directory
|
||||
trees rooted at SOURCE_DIR and BINARY_DIR of <target> are grouped.
|
||||
|
||||
If specified, the common path prefix <strip-source-prefix> of the files inside SOURCE_DIR and
|
||||
the common path prefix <strip-binary-prefix> of the files inside BINARY_DIR gets removed,
|
||||
it is an error if not all paths start with that prefix. Use <strip-prefix> if the same prefix
|
||||
should be used for SOURCE_DIR and BINARY_DIR, the other two parameters must not be specified in that case.
|
||||
|
||||
If <extra-binary-dir> is specified, source files of <target> inside that directory will also get added
|
||||
to the group "Generated Files", no prefix stripping will be applied to these files. If <extra-binary-dir>
|
||||
is not absolute it is interpreted relative to ${CMAKE_CURRENT_BINARY_DIR}. The <extra-binary-dir> may
|
||||
contain BINARY_DIR of <target>, the contents of BINARY_DIR will get excluded when processing <extra-binary-dir>.
|
||||
]]
|
||||
function(set_target_source_groups arg_TARGET)
|
||||
set(options "")
|
||||
set(singleValues STRIP_PREFIX STRIP_SOURCE_PREFIX STRIP_BINARY_PREFIX EXTRA_BINARY_DIRECTORY)
|
||||
set(multiValues "")
|
||||
cmake_parse_arguments(arg "${options}" "${singleValues}" "${multiValues}" ${ARGN})
|
||||
|
||||
get_target_property(sourceDir ${arg_TARGET} SOURCE_DIR)
|
||||
get_target_property(binaryDir ${arg_TARGET} BINARY_DIR)
|
||||
get_target_property(sources ${arg_TARGET} SOURCES)
|
||||
|
||||
if(DEFINED arg_STRIP_PREFIX)
|
||||
if(DEFINED arg_STRIP_SOURCE_PREFIX OR DEFINED arg_STRIP_BINARY_PREFIX)
|
||||
message(FATAL_ERROR "STRIP_PREFIX must not be used together with STRIP_SOURCE_PREFIX or STRIP_BINARY_PREFIX")
|
||||
endif()
|
||||
set(arg_STRIP_SOURCE_PREFIX "${arg_STRIP_PREFIX}")
|
||||
set(arg_STRIP_BINARY_PREFIX "${arg_STRIP_PREFIX}")
|
||||
endif()
|
||||
if(DEFINED arg_STRIP_SOURCE_PREFIX)
|
||||
cmake_path(SET sourceTreeDir NORMALIZE "${sourceDir}/${arg_STRIP_SOURCE_PREFIX}")
|
||||
else()
|
||||
set(sourceTreeDir "${sourceDir}")
|
||||
endif()
|
||||
if(DEFINED arg_STRIP_BINARY_PREFIX)
|
||||
cmake_path(SET binaryTreeDir NORMALIZE "${binaryDir}/${arg_STRIP_BINARY_PREFIX}")
|
||||
else()
|
||||
set(binaryTreeDir "${binaryDir}")
|
||||
endif()
|
||||
if(DEFINED arg_EXTRA_BINARY_DIRECTORY)
|
||||
cmake_path(ABSOLUTE_PATH arg_EXTRA_BINARY_DIRECTORY BASE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" NORMALIZE)
|
||||
endif()
|
||||
|
||||
set(fileSources "")
|
||||
foreach(source IN LISTS sources)
|
||||
cmake_path(ABSOLUTE_PATH source BASE_DIRECTORY "${sourceDir}" NORMALIZE OUTPUT_VARIABLE file)
|
||||
list(APPEND fileSources "${file}")
|
||||
endforeach()
|
||||
# Normally, the build tree is a subdirectory of the source tree. For the root directory the prefix match
|
||||
# will also match the binary tree, so create separate file lists by filtering the binary prefix explicit.
|
||||
# This will fail when doing an in-tree build, in that case everything will be classified as binary.
|
||||
set(sourceFiles "")
|
||||
set(binaryFiles "")
|
||||
foreach(file IN LISTS fileSources)
|
||||
cmake_path(IS_PREFIX sourceDir "${file}" isSourceFile)
|
||||
cmake_path(IS_PREFIX binaryDir "${file}" isBinaryFile)
|
||||
if(isBinaryFile)
|
||||
list(APPEND binaryFiles "${file}")
|
||||
elseif(isSourceFile)
|
||||
list(APPEND sourceFiles "${file}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
set(filterSources "${sourceFiles}")
|
||||
list(FILTER filterSources INCLUDE REGEX "/.+\\.h(h|pp)?$")
|
||||
source_group(
|
||||
TREE "${sourceTreeDir}"
|
||||
PREFIX "Header Files"
|
||||
FILES ${filterSources}
|
||||
)
|
||||
set(filterSources "${sourceFiles}")
|
||||
list(FILTER filterSources INCLUDE REGEX "/.+\\.h(h|pp)?\\.in$")
|
||||
source_group(
|
||||
TREE "${sourceTreeDir}"
|
||||
PREFIX "Header Templates"
|
||||
FILES ${filterSources}
|
||||
)
|
||||
set(filterSources "${sourceFiles}")
|
||||
list(FILTER filterSources INCLUDE REGEX "/.+\\.c(c|xx|pp)?$")
|
||||
source_group(
|
||||
TREE "${sourceTreeDir}"
|
||||
PREFIX "Source Files"
|
||||
FILES ${filterSources}
|
||||
)
|
||||
set(filterSources "${sourceFiles}")
|
||||
list(FILTER filterSources INCLUDE REGEX "/.+\\.c(c|xx|pp)?\\.in$")
|
||||
source_group(
|
||||
TREE "${sourceTreeDir}"
|
||||
PREFIX "Source Templates"
|
||||
FILES ${filterSources}
|
||||
)
|
||||
|
||||
set(filterSources "${binaryFiles}")
|
||||
source_group(
|
||||
TREE "${binaryTreeDir}"
|
||||
PREFIX "Generated Files"
|
||||
FILES ${filterSources}
|
||||
)
|
||||
if(DEFINED arg_EXTRA_BINARY_DIRECTORY)
|
||||
# If the specified directory contains the binary dir of the target, the files will get added
|
||||
# twice with a different path, so exclude that directory.
|
||||
set(filterSources "")
|
||||
foreach(file IN LISTS fileSources)
|
||||
cmake_path(IS_PREFIX arg_EXTRA_BINARY_DIRECTORY "${file}" isExtraBinaryFile)
|
||||
if(isExtraBinaryFile)
|
||||
cmake_path(IS_PREFIX binaryDir "${file}" isBinaryFile)
|
||||
if(NOT isBinaryFile)
|
||||
list(APPEND filterSources "${file}")
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
source_group(
|
||||
TREE "${arg_EXTRA_BINARY_DIRECTORY}"
|
||||
PREFIX "Generated Files"
|
||||
FILES ${filterSources}
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
Reference in New Issue
Block a user