@@ -3,6 +3,68 @@ find_package(PythonExtensions REQUIRED)
3
3
find_package (NumPy REQUIRED )
4
4
find_package (Cython REQUIRED )
5
5
6
+ if (WIN32 )
7
+ string (CONCAT WARNING_FLAGS
8
+ "-Wall "
9
+ "-Wextra "
10
+ "-Winit-self "
11
+ "-Wunused-function "
12
+ "-Wuninitialized "
13
+ "-Wmissing-declarations "
14
+ )
15
+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Ox ${WARNING_FLAGS} " )
16
+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Ox ${WARNING_FLAGS} " )
17
+ set (CMAKE_C_FLAGS_DEBUG
18
+ "${CMAKE_C_FLAGS_DEBUG} ${WARNING_FLAGS} -ggdb3 -DDEBUG"
19
+ )
20
+ set (CMAKE_CXX_FLAGS_DEBUG
21
+ "${CMAKE_CXX_FLAGS_DEBUG} ${WARNING_FLAGS} -ggdb3 -DDEBUG"
22
+ )
23
+ set (DPCTL_LDFLAGS "/NXCompat /DynamicBase" )
24
+ elseif (UNIX )
25
+ string (CONCAT WARNING_FLAGS
26
+ "-Wall "
27
+ "-Wextra "
28
+ "-Winit-self "
29
+ "-Wunused-function "
30
+ "-Wuninitialized "
31
+ "-Wmissing-declarations "
32
+ "-fdiagnostics-color=auto "
33
+ "-Wno-deprecated-declarations "
34
+ )
35
+ string (CONCAT SDL_FLAGS
36
+ "-fstack-protector "
37
+ "-fstack-protector-all "
38
+ "-fpic "
39
+ "-fPIC "
40
+ "-D_FORTIFY_SOURCE=2 "
41
+ "-Wformat "
42
+ "-Wformat-security "
43
+ "-fno-strict-overflow "
44
+ "-fno-delete-null-pointer-checks "
45
+ )
46
+ string (CONCAT CFLAGS
47
+ "${WARNING_FLAGS} "
48
+ "${SDL_FLAGS} "
49
+ )
50
+ string (CONCAT CXXFLAGS
51
+ "${WARNING_FLAGS} "
52
+ "${SDL_FLAGS} "
53
+ "-fsycl "
54
+ )
55
+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 ${CFLAGS} " )
56
+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 ${CXXFLAGS} " )
57
+ set (CMAKE_C_FLAGS_DEBUG
58
+ "${CMAKE_C_FLAGS_DEBUG} ${CFLAGS} -ggdb3 -DDEBUG"
59
+ )
60
+ set (CMAKE_CXX_FLAGS_DEBUG
61
+ "${CMAKE_CXX_FLAGS_DEBUG} ${CXXFLAGS} -ggdb3 -DDEBUG"
62
+ )
63
+ set (DPCTL_LDFLAGS "-z,noexecstack,-z,relro,-z,now" )
64
+ else ()
65
+ message (FATAL_ERROR "Unsupported system." )
66
+ endif ()
67
+
6
68
# at build time create include/ directory and copy header files over
7
69
set (DPCTL_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} /include )
8
70
add_custom_target (_build_time_create_dpctl_include ALL
@@ -21,6 +83,7 @@ function(build_dpctl_ext _trgt _src _dest)
21
83
target_include_directories (${_trgt} PRIVATE ${NumPy_INCLUDE_DIR} ${DPCTL_INCLUDE_DIR} )
22
84
add_dependencies (${_trgt} _build_time_create_dpctl_include )
23
85
target_link_libraries (${_trgt} DPCTLSyclInterface )
86
+ target_link_options (${_trgt} PRIVATE "LINKER:${DPCTL_LDFLAGS} " )
24
87
python_extension_module (${_trgt} )
25
88
get_filename_component (_name_wle ${_generated_src} NAME_WLE )
26
89
get_filename_component (_generated_src_dir ${_generated_src} DIRECTORY )
0 commit comments