File: DefinePlatformSpecific.cmake

package info (click to toggle)
poco 1.14.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 56,460 kB
  • sloc: cpp: 340,542; ansic: 245,601; makefile: 1,742; yacc: 1,005; sh: 698; sql: 312; lex: 282; xml: 128; perl: 29; python: 24
file content (92 lines) | stat: -rw-r--r-- 3,549 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# 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
# using CMake variable CMAKE_MSVC_RUNTIME_LIBRARY.
#
# 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(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
		set(STATIC_POSTFIX "mt" CACHE STRING "Set static library postfix" FORCE)
	else(POCO_MT)
		set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
		set(STATIC_POSTFIX "md" CACHE STRING "Set static library postfix" FORCE)
	endif(POCO_MT)

	message(STATUS "MSVC runtime library: ${CMAKE_MSVC_RUNTIME_LIBRARY}")

	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
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)
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()

# MacOS version that has full support for C++17
set(CMAKE_OSX_DEPLOYMENT_TARGET, 10.15)

# OS Detection
include(CheckTypeSize)
find_package(Cygwin)