poco/cmake/DefinePlatformSpecific.cmake

104 lines
3.6 KiB
CMake
Raw Normal View History

# http://www.cmake.org/Wiki/CMake_Useful_Variables :
# CMAKE_BUILD_TYPE
# Choose the type of build. CMake has default flags for these:
#
# * None (CMAKE_C_FLAGS or CMAKE_CXX_FLAGS used)
# * Debug (CMAKE_C_FLAGS_DEBUG or CMAKE_CXX_FLAGS_DEBUG)
# * Release (CMAKE_C_FLAGS_RELEASE or CMAKE_CXX_FLAGS_RELEASE)
# * RelWithDebInfo (CMAKE_C_FLAGS_RELWITHDEBINFO or CMAKE_CXX_FLAGS_RELWITHDEBINFO
# * MinSizeRel (CMAKE_C_FLAGS_MINSIZEREL or CMAKE_CXX_FLAGS_MINSIZEREL)
# Setting CXX Flag /MD or /MT and POSTFIX values i.e MDd / MD / MTd / MT / d
#
# For visual studio the library naming is as following:
# Dynamic libraries:
# - PocoX.dll for release library
# - PocoXd.dll for debug library
#
# Static libraries:
# - PocoXmd.lib for /MD release build
# - PocoXtmt.lib for /MT release build
#
# - PocoXmdd.lib for /MD debug build
# - PocoXmtd.lib for /MT debug build
if(BUILD_SHARED_LIBS)
add_compile_definitions(POCO_DLL)
else()
add_compile_definitions(POCO_STATIC)
endif()
if(MSVC)
if(POCO_MT)
set(CompilerFlags
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_C_FLAGS_MINSIZEREL
)
foreach(CompilerFlag ${CompilerFlags})
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
endforeach()
set(STATIC_POSTFIX "mt" CACHE STRING "Set static library postfix" FORCE)
else(POCO_MT)
set(STATIC_POSTFIX "md" CACHE STRING "Set static library postfix" FORCE)
endif(POCO_MT)
if(POCO_SANITIZE_ASAN)
message(WARNING "Use POCO_SANITIZEFLAGS instead of POCO_SANITIZE_ASAN")
add_compile_options("/fsanitize=address")
endif()
else(MSVC)
# Other compilers then MSVC don't have a static STATIC_POSTFIX at the moment
set(STATIC_POSTFIX "" CACHE STRING "Set static library postfix" FORCE)
endif(MSVC)
if (DEFINED POCO_SANITIZEFLAGS AND NOT "${POCO_SANITIZEFLAGS}" STREQUAL "")
message(STATUS "Using sanitize flags: ${POCO_SANITIZEFLAGS}")
add_compile_options(${POCO_SANITIZEFLAGS})
add_link_options(${POCO_SANITIZEFLAGS})
endif()
if (ENABLE_COMPILER_WARNINGS)
message(STATUS "Enabling additional compiler warning flags.")
# Additional compiler-specific warning flags
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# using clang
add_compile_options(-Wall -Wextra -Wpedantic -Wno-unused-parameter)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# using GCC
add_compile_options(-Wall -Wextra -Wpedantic -Wno-unused-parameter)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# using Visual Studio C++
add_compile_options(/W4)
endif()
endif()
# Add a d postfix to the debug libraries
2020-02-12 22:10:01 +01:00
if(BUILD_SHARED_LIBS)
set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Set Debug library postfix" FORCE)
set(CMAKE_RELEASE_POSTFIX "" CACHE STRING "Set Release library postfix" FORCE)
set(CMAKE_MINSIZEREL_POSTFIX "" CACHE STRING "Set MinSizeRel library postfix" FORCE)
set(CMAKE_RELWITHDEBINFO_POSTFIX "" CACHE STRING "Set RelWithDebInfo library postfix" FORCE)
2020-02-12 22:10:01 +01:00
else(BUILD_SHARED_LIBS)
set(CMAKE_DEBUG_POSTFIX "${STATIC_POSTFIX}d" CACHE STRING "Set Debug library postfix" FORCE)
set(CMAKE_RELEASE_POSTFIX "${STATIC_POSTFIX}" CACHE STRING "Set Release library postfix" FORCE)
set(CMAKE_MINSIZEREL_POSTFIX "${STATIC_POSTFIX}" CACHE STRING "Set MinSizeRel library postfix" FORCE)
set(CMAKE_RELWITHDEBINFO_POSTFIX "${STATIC_POSTFIX}" CACHE STRING "Set RelWithDebInfo library postfix" FORCE)
endif()
enh(Poco::ActiveThreadPool): make it easy to use correctly (#4624) * make Poco::ActiveThreadPool easy to use (#4544) * code format * Fix ThreadSanitizer thread leak error * enh(ActivePooledThread): Change pointers to references * enh(ActivePooledThread): remove unused method * enh(Poco::ActiveThreadPool): Use std::unique_ptr instead of raw pointer * enh(Poco::ActiveThreadPool): Use C++ static_cast instead of C casting * enh(Poco::ActiveThreadPool): Use standard containers instead of implementing own * enh(Poco::ActiveThreadPool): Change pointer to reference * enh(Poco::ActiveThreadPool): Use smart pointers instead of bare pointers * enh(Poco::ActiveThreadPool): Fix codeql warning: A stack address which arrived via a may be assigned to a non-local variable. * enh(Poco::ActiveThreadPool): More test case * enh(Poco::ActiveThreadPool): std::optional::value unavailable on earlier macOS versions * enh(Poco::ActiveThreadPool): Fix compare function for make heap * enh(Poco::ActiveThreadPool): Add more test case * enh(Poco::ActiveThreadPool): Add more test case * enh(Poco::ActiveThreadPool): Code style * enh(Poco::ActiveThreadPool): Test case * enh(Poco::ActiveThreadPool): Test case * enh(Poco::ActiveThreadPool): Fix test case error * Revert "enh(Poco::ActiveThreadPool): std::optional::value unavailable on earlier macOS versions" This reverts commit cba4673b47761192d118eadf320b92f880071404. * enh(macOS): require min deployment macOS version 10.15 which has full support for C++17 * enh(Poco::ActiveThreadPool): Remove useless "{}" * enh(Poco::ActiveThreadPool): Rename member variable m_impl to _impl --------- Co-authored-by: Matej Kenda <matejken@gmail.com>
2024-08-30 11:54:44 +02:00
# MacOS version that has full support for C++17
set(CMAKE_OSX_DEPLOYMENT_TARGET, 10.15)
# OS Detection
include(CheckTypeSize)
find_package(Cygwin)