Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
27a4a2c9
Commit
27a4a2c9
authored
Oct 11, 2015
by
Davis King
Browse files
Made this macro work for switch strings that have what look like regular
expressions in them to cmake.
parent
914deffc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
4 deletions
+9
-4
dlib/add_global_compiler_switch.cmake
dlib/add_global_compiler_switch.cmake
+9
-4
No files found.
dlib/add_global_compiler_switch.cmake
View file @
27a4a2c9
cmake_minimum_required
(
VERSION 2.8.4
)
# Make macros that can add compiler switches to the entire project. Not just
# to the current cmake folder being built.
macro
(
add_global_compiler_switch switch_name
)
if
(
NOT CMAKE_CXX_FLAGS MATCHES
"
${
switch_name
}
"
)
# If removing the switch would change the flags then it's already present
# and we don't need to do anything.
string
(
REPLACE
"
${
switch_name
}
"
""
tempstr
"
${
CMAKE_CXX_FLAGS
}
"
)
if
(
"
${
CMAKE_CXX_FLAGS
}
"
STREQUAL
"
${
tempstr
}
"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
${
switch_name
}
"
CACHE STRING
"Flags used by the compiler during all C++ builds."
FORCE
)
...
...
@@ -11,9 +16,9 @@ macro ( add_global_compiler_switch switch_name )
endmacro
()
macro
(
remove_global_compiler_switch switch_name
)
if
(
CMAKE_CXX_FLAGS MATCHES
"
${
switch_name
}
"
)
string
(
REGEX REPLACE
"
${
switch_name
}
"
""
temp_var
${
CMAKE_CXX_FLAGS
}
)
set
(
CMAKE_CXX_FLAGS
"
${
temp
_va
r
}
"
string
(
REPLACE
"
${
switch_name
}
"
""
tempstr
"
${
CMAKE_CXX_FLAGS
}
"
)
if
(
NOT
"
${
CMAKE_CXX_FLAGS
}
"
STREQUAL
"
${
tempstr
}
"
)
set
(
CMAKE_CXX_FLAGS
"
${
temp
st
r
}
"
CACHE STRING
"Flags used by the compiler during all C++ builds."
FORCE
)
endif
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment