24
24
CMAKE_MINIMUM_REQUIRED (VERSION 3.0.2 )
25
25
26
26
macro (CeleroSetDefaultCompilerOptions )
27
+ set_target_properties (${PROJECT_NAME} PROPERTIES
28
+ POSITION_INDEPENDENT_CODE "${CELERO_COMPILE_PIC} "
29
+ )
27
30
if (${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC )
28
31
target_compile_options (${PROJECT_NAME} PRIVATE /D_VARIADIC_MAX=10 )
29
32
target_compile_options (${PROJECT_NAME} PRIVATE /D_CRT_SECURE_NO_WARNINGS )
30
33
target_compile_options (${PROJECT_NAME} PRIVATE /wd4251 )
31
34
target_compile_options (${PROJECT_NAME} PRIVATE /MP )
32
35
target_compile_options (${PROJECT_NAME} PRIVATE /D_SCL_SECURE_NO_WARNINGS )
33
36
target_compile_options (${PROJECT_NAME} PRIVATE /permissive- )
34
- target_compile_options (${PROJECT_NAME} PRIVATE /std:c++14 )
35
37
36
38
if (CELERO_TREAT_WARNINGS_AS_ERRORS )
37
39
target_compile_options (${PROJECT_NAME} PRIVATE /WX )
38
40
endif ()
41
+ set_target_properties (${PROJECT_NAME} PROPERTIES
42
+ ARCHIVE_OUTPUT_NAME "${PROJECT_NAME} .dll" )
39
43
40
44
elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL GNU )
41
45
target_compile_options (${PROJECT_NAME} PRIVATE -Wall )
42
- target_compile_options (${PROJECT_NAME} PRIVATE -fPIC )
43
- target_compile_options (${PROJECT_NAME} PRIVATE -std=c++14 )
44
46
45
47
elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL Clang )
46
48
if (${CMAKE_SYSTEM_NAME} STREQUAL Windows )
47
- target_compile_options (${PROJECT_NAME} PRIVATE -Xclang -std=c++14 )
49
+ target_compile_options (${PROJECT_NAME} PRIVATE -Xclang )
48
50
target_compile_options (${PROJECT_NAME} PRIVATE -Wno-c++98-compat )
49
51
target_compile_options (${PROJECT_NAME} PRIVATE -Wno-c++98-compat-pedantic )
50
52
target_compile_options (${PROJECT_NAME} PRIVATE -Wno-reserved-id-macro )
@@ -53,17 +55,13 @@ macro(CeleroSetDefaultCompilerOptions)
53
55
endif ()
54
56
else ()
55
57
target_compile_options (${PROJECT_NAME} PRIVATE -Wall )
56
- target_compile_options (${PROJECT_NAME} PRIVATE -fPIC )
57
- target_compile_options (${PROJECT_NAME} PRIVATE -std=c++14 )
58
58
if (CELERO_TREAT_WARNINGS_AS_ERRORS )
59
59
target_compile_options (${PROJECT_NAME} PRIVATE -Werror )
60
60
endif ()
61
61
endif ()
62
62
63
63
elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL AppleClang )
64
64
target_compile_options (${PROJECT_NAME} PRIVATE -Wall )
65
- target_compile_options (${PROJECT_NAME} PRIVATE -fPIC )
66
- target_compile_options (${PROJECT_NAME} PRIVATE -std=c++14 )
67
65
68
66
if (CELERO_TREAT_WARNINGS_AS_ERRORS )
69
67
target_compile_options (${PROJECT_NAME} PRIVATE -Werror )
@@ -83,6 +81,7 @@ include(CheckIncludeFile)
83
81
#
84
82
85
83
option (CELERO_COMPILE_DYNAMIC_LIBRARIES "Set to ON to build Celero for dynamic linking. Use OFF for static." ON )
84
+ option (CELERO_COMPILE_PIC "Set to ON to build Celero as a position-independent library." ON )
86
85
option (CELERO_ENABLE_EXPERIMENTS "Set to ON to automatically build all examples." OFF )
87
86
option (CELERO_ENABLE_FOLDERS "Enable to put Celero in its own solution folder under Visual Studio" ON )
88
87
option (CELERO_ENABLE_TESTS "Enable building and running unit tests." OFF )
@@ -101,6 +100,7 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
101
100
#
102
101
103
102
set (CMAKE_CXX_STANDARD 14 )
103
+ set (CMAKE_CXX_EXTENSIONS OFF )
104
104
105
105
set (CMAKE_DEBUG_POSTFIX "d" CACHE STRING "add a postfix, usually d on windows" )
106
106
set (CMAKE_RELEASE_POSTFIX "" CACHE STRING "add a postfix, usually empty on windows" )
@@ -176,9 +176,9 @@ target_sources(${PROJECT_NAME} PRIVATE
176
176
src/Utilities.cpp
177
177
)
178
178
179
- if (MSVC )
179
+ if (WIN32 )
180
180
set (SYSLIBS
181
- PowrProf.lib
181
+ powrprof psapi
182
182
)
183
183
else ()
184
184
#pthread is required for std::thread to work.
@@ -204,7 +204,7 @@ install(TARGETS ${PROJECT_NAME}
204
204
EXPORT ${PROJECT_NAME} -target
205
205
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX} /bin
206
206
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX} /lib
207
- ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX} /lib/static
207
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX} /lib
208
208
)
209
209
210
210
install (DIRECTORY include DESTINATION ${CMAKE_INSTALL_PREFIX} )
0 commit comments