Skip to content

Commit 669d248

Browse files
committed
Merge pull request #695 from skrah/append_cxxflags
Allow proper overriding of CXXFLAGS.
2 parents 2bcac16 + a117601 commit 669d248

1 file changed

Lines changed: 24 additions & 23 deletions

File tree

CMakeLists.txt

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,33 @@ string(REPLACE "v" "" DYND_PYTHON_VERSION "${DYND_PYTHON_VERSION_STRING}")
120120
string(REPLACE "-" ";" DYND_PYTHON_VERSION "${DYND_PYTHON_VERSION}")
121121
list(GET DYND_PYTHON_VERSION 0 "${DYND_PYTHON_VERSION}")
122122

123+
if(MSVC)
124+
set(CMAKE_CXX_FLAGS "-DHAVE_ROUND ${CMAKE_CXX_FLAGS}")
125+
else()
126+
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
127+
if(APPLE)
128+
set(CMAKE_CXX_FLAGS "-Wno-unused-parameter -Wno-unused-function -Wno-error ${CMAKE_CXX_FLAGS}")
129+
else()
130+
set(CMAKE_CXX_FLAGS "-Wno-error ${CMAKE_CXX_FLAGS}")
131+
endif()
132+
endif()
133+
123134
if(MSVC)
124135
# Treat warnings as errors (-WX does this)
125-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -WX -EHsc")
136+
set(CMAKE_CXX_FLAGS "-WX -EHsc ${CMAKE_CXX_FLAGS}")
126137
if (${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 18)
127138
message(FATAL_ERROR "Only MSVC 2013 (Version 18.0) and later are supported by LibDyND. Found version ${CMAKE_CXX_COMPILER_VERSION}.")
128139
endif ()
129140
else()
141+
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
142+
if ("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS 4.9)
143+
message(FATAL_ERROR "Only GCC 4.9 and later are supported by DyND. Found version ${CMAKE_CXX_COMPILER_VERSION}.")
144+
endif()
145+
set(CMAKE_CXX_FLAGS "-std=c++14 -fmax-errors=20 ${CMAKE_CXX_FLAGS}")
146+
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
147+
set(CMAKE_CXX_FLAGS "-std=c++1y -ferror-limit=20 -Wdocumentation ${CMAKE_CXX_FLAGS}")
148+
endif()
149+
130150
if(WIN32)
131151
# Don't use the -fPIC flag since it is the default on MinGW.
132152
# Doing so results in a warning that is then raised as an error.
@@ -135,31 +155,12 @@ else()
135155
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
136156
# Define MS_WIN64 so that npy_intp has the correct size and
137157
# the proper module import functions are called on 64 bit Windows.
138-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_hypot=hypot -std=c++14 -DMS_WIN64 -g -fomit-frame-pointer -fstrict-aliasing -Wall -Wextra -Werror -Wno-missing-field-initializers")
158+
set(CMAKE_CXX_FLAGS "-D_hypot=hypot -std=c++14 -DMS_WIN64 -g -fomit-frame-pointer -fstrict-aliasing -Wall -Wextra -Werror -Wno-missing-field-initializers ${CMAKE_CXX_FLAGS}")
139159
else()
140-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_hypot=hypot -std=c++14 -g -fomit-frame-pointer -fstrict-aliasing -Wall -Wextra -Werror -Wno-missing-field-initializers")
160+
set(CMAKE_CXX_FLAGS "-D_hypot=hypot -std=c++14 -g -fomit-frame-pointer -fstrict-aliasing -Wall -Wextra -Werror -Wno-missing-field-initializers ${CMAKE_CXX_FLAGS}")
141161
endif()
142162
else()
143-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fomit-frame-pointer -fstrict-aliasing -fPIC -Wall -Wextra -Werror -Wno-missing-field-initializers")
144-
endif()
145-
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
146-
if ("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS 4.9)
147-
message(FATAL_ERROR "Only GCC 4.9 and later are supported by DyND. Found version ${CMAKE_CXX_COMPILER_VERSION}.")
148-
endif()
149-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -fmax-errors=20")
150-
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
151-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y -ferror-limit=20 -Wdocumentation")
152-
endif()
153-
endif()
154-
155-
if(MSVC)
156-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_ROUND")
157-
else()
158-
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
159-
if(APPLE)
160-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter -Wno-unused-function -Wno-error")
161-
else()
162-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error")
163+
set(CMAKE_CXX_FLAGS "-g -fomit-frame-pointer -fstrict-aliasing -fPIC -Wall -Wextra -Werror -Wno-missing-field-initializers ${CMAKE_CXX_FLAGS}")
163164
endif()
164165
endif()
165166

0 commit comments

Comments
 (0)