File tree Expand file tree Collapse file tree 18 files changed +60
-36
lines changed Expand file tree Collapse file tree 18 files changed +60
-36
lines changed Original file line number Diff line number Diff line change @@ -52,17 +52,7 @@ if(MSVC)
52
52
set (CUSTOM_COMMAND_BINARY_DIR ${CUSTOM_COMMAND_BINARY_DIR} /$<CONFIG> )
53
53
endif ()
54
54
55
- # CXX flags setup
56
55
if (NOT MSVC )
57
- add_compile_options (-fPIC -Wall -Wpedantic
58
- $< $< CXX_COMPILER_ID:GNU> :-fdiagnostics-color=always>
59
- $< $< CXX_COMPILER_ID:Clang,AppleClang> :-fcolor-diagnostics> )
60
- if (CMAKE_BUILD_TYPE STREQUAL "Release" )
61
- add_compile_options (-D_FORTIFY_SOURCE=2 )
62
- endif ()
63
- if (UR_DEVELOPER_MODE )
64
- add_compile_options (-Werror -fno-omit-frame-pointer -fstack-protector-strong )
65
- endif ()
66
56
# Determine if libstdc++ is being used.
67
57
check_cxx_source_compiles ("
68
58
#include <array>
@@ -78,14 +68,6 @@ if(NOT MSVC)
78
68
# is available we still need to link this library.
79
69
link_libraries (stdc++fs )
80
70
endif ()
81
- elseif (MSVC )
82
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP" )
83
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP" )
84
- add_compile_options (/MP /W3 /MD$<$<CONFIG:Debug>:d> )
85
-
86
- if (UR_DEVELOPER_MODE )
87
- add_compile_options (/WX /GS )
88
- endif ()
89
71
endif ()
90
72
91
73
if (UR_ENABLE_TRACING )
Original file line number Diff line number Diff line change @@ -57,6 +57,48 @@ macro(add_sanitizer_flag flag)
57
57
set (CMAKE_REQUIRED_LIBRARIES ${SAVED_CMAKE_REQUIRED_LIBRARIES} )
58
58
endmacro ()
59
59
60
+ function (add_ur_target_compile_options name )
61
+ if (NOT MSVC )
62
+ target_compile_options (${name} PRIVATE
63
+ -fPIC
64
+ -Wall
65
+ -Wpedantic
66
+ $< $< CXX_COMPILER_ID:GNU> :-fdiagnostics-color=always>
67
+ $< $< CXX_COMPILER_ID:Clang,AppleClang> :-fcolor-diagnostics>
68
+ )
69
+ if (CMAKE_BUILD_TYPE STREQUAL "Release" )
70
+ target_compile_definitions (${name} PRIVATE -D_FORTIFY_SOURCE=2 )
71
+ endif ()
72
+ if (UR_DEVELOPER_MODE )
73
+ target_compile_options (${name} PRIVATE
74
+ -Werror
75
+ -fno-omit-frame-pointer
76
+ -fstack-protector-strong
77
+ )
78
+ endif ()
79
+ elseif (MSVC )
80
+ target_compile_options (${name} PRIVATE
81
+ /MP
82
+ /W3
83
+ /MD$<$<CONFIG:Debug>:d>
84
+ )
85
+
86
+ if (UR_DEVELOPER_MODE )
87
+ target_compile_options (${name} PRIVATE /WX /GS )
88
+ endif ()
89
+ endif ()
90
+ endfunction ()
91
+
92
+ function (add_ur_executable name )
93
+ add_executable (${name} ${ARGN} )
94
+ add_ur_target_compile_options (${name} )
95
+ endfunction ()
96
+
97
+ function (add_ur_library name )
98
+ add_library (${name} ${ARGN} )
99
+ add_ur_target_compile_options (${name} )
100
+ endfunction ()
101
+
60
102
include (FetchContent )
61
103
62
104
# A wrapper around FetchContent_Declare that supports git sparse checkout.
Original file line number Diff line number Diff line change 5
5
6
6
set (TARGET_NAME collector )
7
7
8
- add_library (${TARGET_NAME} SHARED
8
+ add_ur_library (${TARGET_NAME} SHARED
9
9
${CMAKE_CURRENT_SOURCE_DIR} /collector.cpp
10
10
)
11
11
Original file line number Diff line number Diff line change 5
5
6
6
set (TARGET_NAME hello_world )
7
7
8
- add_executable (${TARGET_NAME}
8
+ add_ur_executable (${TARGET_NAME}
9
9
${CMAKE_CURRENT_SOURCE_DIR} /hello_world.cpp
10
10
)
11
11
Original file line number Diff line number Diff line change 5
5
6
6
set (TARGET_NAME ur_adapter_null )
7
7
8
- add_library (${TARGET_NAME}
8
+ add_ur_library (${TARGET_NAME}
9
9
SHARED
10
10
${CMAKE_CURRENT_SOURCE_DIR} /ur_null.hpp
11
11
${CMAKE_CURRENT_SOURCE_DIR} /ur_null.cpp
Original file line number Diff line number Diff line change 3
3
# See LICENSE.TXT
4
4
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5
5
6
- add_library (disjoint_pool STATIC
6
+ add_ur_library (disjoint_pool STATIC
7
7
disjoint_pool.cpp
8
8
disjoint_pool_config_parser.cpp
9
9
)
Original file line number Diff line number Diff line change @@ -14,11 +14,11 @@ if(UMF_BUILD_SHARED_LIBRARY)
14
14
message (WARNING "Unified Malloc Framework is still an early work in progress."
15
15
"There are no API/ABI backward compatibility guarantees. There will be breakages."
16
16
"Do not use the shared library in production software." )
17
- add_library (unified_malloc_framework SHARED
17
+ add_ur_library (unified_malloc_framework SHARED
18
18
${UMF_SOURCES} )
19
19
target_compile_definitions (unified_malloc_framework PUBLIC UMF_SHARED_LIBRARY )
20
20
else ()
21
- add_library (unified_malloc_framework STATIC
21
+ add_ur_library (unified_malloc_framework STATIC
22
22
${UMF_SOURCES} )
23
23
endif ()
24
24
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ configure_file(
9
9
@ONLY
10
10
)
11
11
12
- add_library (ur_loader
12
+ add_ur_library (ur_loader
13
13
SHARED
14
14
""
15
15
${CMAKE_CURRENT_BINARY_DIR} /UrLoaderVersion.rc
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ set(UR_CONFORMANCE_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR})
7
7
8
8
function (add_conformance_test name )
9
9
set (TEST_TARGET_NAME test -${name} )
10
- add_executable (${TEST_TARGET_NAME}
10
+ add_ur_executable (${TEST_TARGET_NAME}
11
11
${ARGN}
12
12
${UR_CONFORMANCE_TEST_DIR} /source/environment.cpp
13
13
${UR_CONFORMANCE_TEST_DIR} /source/main.cpp )
Original file line number Diff line number Diff line change 3
3
# See LICENSE.TXT
4
4
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5
5
6
- add_library (ur_testing STATIC
6
+ add_ur_library (ur_testing STATIC
7
7
source /utils.cpp )
8
8
target_include_directories (ur_testing PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} /include )
9
9
target_link_libraries (ur_testing PRIVATE gtest_main unified-runtime::headers )
You can’t perform that action at this time.
0 commit comments