mirror of
https://gitee.com/openharmony/third_party_nghttp2
synced 2024-11-27 01:50:28 +00:00
cmake: fix compatibility with cmake before 3.3
The COMPILE_LANGUAGE generator expression is only supported since CMake 3.3. Moreover, it does not work with all generators (works with Makefile and Ninja, but not with Visual Studio). target_compile_options would only work if a target does not mix C and C++ sources, since the flags are intended to be set for a specific language, use set_source_files_properties instead. This approach is also less repetitive. Drop the idea of using lists and COMPILE_OPTIONS, set_source_files_properties only understands COMPILE_FLAGS (a single string, not a list).
This commit is contained in:
parent
bdb6581990
commit
7f8110601e
@ -1,11 +1,10 @@
|
||||
if(ENABLE_EXAMPLES)
|
||||
# XXX replace this by lists (WARNCFLAGS_list)
|
||||
string(REPLACE " " ";" c_flags "${WARNCFLAGS}")
|
||||
string(REPLACE " " ";" cxx_flags "${WARNCXXFLAGS} ${CXX1XCXXFLAGS}")
|
||||
add_compile_options(
|
||||
"$<$<COMPILE_LANGUAGE:C>:${c_flags}>"
|
||||
"$<$<COMPILE_LANGUAGE:CXX>:${cxx_flags}>"
|
||||
)
|
||||
file(GLOB c_sources *.c)
|
||||
set_source_files_properties(${c_sources} PROPERTIES
|
||||
COMPILE_FLAGS "${WARNCFLAGS}")
|
||||
file(GLOB cxx_sources *.cc)
|
||||
set_source_files_properties(${cxx_sources} PROPERTIES
|
||||
COMPILE_FLAGS "${WARNCXXFLAGS} ${CXX1XCXXFLAGS}")
|
||||
|
||||
include_directories(
|
||||
${CMAKE_SOURCE_DIR}
|
||||
|
@ -26,7 +26,6 @@ set(NGHTTP2_SOURCES
|
||||
|
||||
# Public shared library
|
||||
add_library(nghttp2 SHARED ${NGHTTP2_SOURCES})
|
||||
# Needed because the object files are linked into a shared library.
|
||||
set_target_properties(nghttp2 PROPERTIES
|
||||
COMPILE_FLAGS "${WARNCFLAGS}"
|
||||
VERSION ${LT_VERSION} SOVERSION ${LT_SOVERSION}
|
||||
|
@ -1,12 +1,11 @@
|
||||
add_subdirectory(includes)
|
||||
|
||||
# XXX replace this by lists (WARNCFLAGS_list)
|
||||
string(REPLACE " " ";" c_flags "${WARNCFLAGS}")
|
||||
string(REPLACE " " ";" cxx_flags "${WARNCXXFLAGS} ${CXX1XCXXFLAGS}")
|
||||
add_compile_options(
|
||||
"$<$<COMPILE_LANGUAGE:C>:${c_flags}>"
|
||||
"$<$<COMPILE_LANGUAGE:CXX>:${cxx_flags}>"
|
||||
)
|
||||
file(GLOB c_sources *.c)
|
||||
set_source_files_properties(${c_sources} PROPERTIES
|
||||
COMPILE_FLAGS "${WARNCFLAGS}")
|
||||
file(GLOB cxx_sources *.cc)
|
||||
set_source_files_properties(${cxx_sources} PROPERTIES
|
||||
COMPILE_FLAGS "${WARNCXXFLAGS} ${CXX1XCXXFLAGS}")
|
||||
|
||||
include_directories(
|
||||
"${CMAKE_SOURCE_DIR}/lib/includes"
|
||||
@ -246,7 +245,6 @@ if(ENABLE_ASIO_LIB)
|
||||
${OPENSSL_LIBRARIES}
|
||||
${Boost_LIBRARIES}
|
||||
)
|
||||
# XXX use add_compile_options with a list instead of COMPILE_FLAGS
|
||||
set_target_properties(nghttp2_asio PROPERTIES
|
||||
VERSION 1.0.0 SOVERSION 1)
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
# XXX testdata/: EXTRA_DIST = cacert.pem index.html privkey.pem
|
||||
if(HAVE_CUNIT)
|
||||
# XXX replace this by lists (WARNCFLAGS_list)
|
||||
string(REPLACE " " ";" c_flags "${WARNCFLAGS}")
|
||||
add_compile_options(${c_flags})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user