mirror of
https://github.com/libssh2/libssh2.git
synced 2025-10-26 02:17:35 +03:00
cmake: pass picky C options to C targets only (and not to C++ ossfuzz)
This also means that we no longer pass any picky warning option to ossfuzz. It's probably not worth maintaining picky C++ options for this single, small target. Silencing: ``` cc1plus: warning: command-line option '-Wbad-function-cast' is valid for C/ObjC but not for C++ cc1plus: warning: command-line option '-Wdeclaration-after-statement' is valid for C/ObjC but not for C++ cc1plus: warning: command-line option '-Wenum-int-mismatch' is valid for C/ObjC but not for C++ cc1plus: warning: command-line option '-Wjump-misses-init' is valid for C/ObjC but not for C++ cc1plus: warning: command-line option '-Wmissing-parameter-type' is valid for C/ObjC but not for C++ cc1plus: warning: command-line option '-Wmissing-prototypes' is valid for C/ObjC but not for C++ cc1plus: warning: command-line option '-Wnested-externs' is valid for C/ObjC but not for C++ cc1plus: warning: command-line option '-Wold-style-declaration' is valid for C/ObjC but not for C++ cc1plus: warning: command-line option '-Wold-style-definition' is valid for C/ObjC but not for C++ cc1plus: warning: command-line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++ ``` Ref: https://github.com/libssh2/libssh2/actions/runs/18063134305/job/51402236388#step:7:15 Closes #1686
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
|
||||
include(CheckCCompilerFlag)
|
||||
|
||||
set(LIBSSH2_PICKY_C_FLAGS "")
|
||||
|
||||
set(_picky "")
|
||||
set(_picky_nocheck "") # not to pass to feature checks
|
||||
|
||||
@@ -294,7 +296,7 @@ if(_picky_nocheck OR _picky)
|
||||
string(REPLACE ";" " " _picky_tmp "${_picky_tmp}")
|
||||
string(STRIP "${_picky_tmp}" _picky_tmp)
|
||||
message(STATUS "Picky compiler options: ${_picky_tmp}")
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS "${_picky_nocheck}" "${_picky}")
|
||||
set(LIBSSH2_PICKY_C_FLAGS "${_picky_nocheck}" "${_picky}")
|
||||
|
||||
# Apply to all feature checks
|
||||
string(REPLACE ";" " " _picky_tmp "${_picky}")
|
||||
|
||||
@@ -52,7 +52,7 @@ foreach(_example IN LISTS noinst_PROGRAMS)
|
||||
"${PROJECT_BINARY_DIR}/src"
|
||||
"${PROJECT_SOURCE_DIR}/src")
|
||||
target_link_libraries(${_example} ${LIB_SELECTED} ${LIBSSH2_LIBS})
|
||||
set_target_properties(${_example} PROPERTIES UNITY_BUILD OFF)
|
||||
set_target_properties(${_example} PROPERTIES COMPILE_OPTIONS "${LIBSSH2_PICKY_C_FLAGS}" UNITY_BUILD OFF)
|
||||
endforeach()
|
||||
|
||||
libssh2_add_target_to_copy_dependencies(
|
||||
|
||||
@@ -113,6 +113,7 @@ if(BUILD_STATIC_LIBS OR BUILD_STATIC_FOR_TESTS)
|
||||
add_library(${LIB_STATIC} STATIC ${_sources})
|
||||
add_library(${PROJECT_NAME}::${LIB_STATIC} ALIAS ${LIB_STATIC})
|
||||
target_compile_definitions(${LIB_STATIC} PRIVATE ${CRYPTO_BACKEND_DEFINE} ${_libssh2_definitions})
|
||||
target_compile_options(${LIB_STATIC} PRIVATE "${LIBSSH2_PICKY_C_FLAGS}")
|
||||
target_link_libraries(${LIB_STATIC} PRIVATE ${LIBSSH2_LIBS})
|
||||
set_target_properties(${LIB_STATIC} PROPERTIES
|
||||
PREFIX "" OUTPUT_NAME "libssh2" SOVERSION "${_libssh2_soversion}" VERSION "${_libssh2_libversion}"
|
||||
@@ -156,7 +157,7 @@ if(BUILD_SHARED_LIBS)
|
||||
set_property(TARGET ${LIB_SHARED} APPEND PROPERTY SOURCES "libssh2.rc")
|
||||
endif()
|
||||
target_compile_definitions(${LIB_SHARED} PRIVATE ${CRYPTO_BACKEND_DEFINE} ${_libssh2_definitions} ${LIB_SHARED_DEFINITIONS})
|
||||
target_compile_options(${LIB_SHARED} PRIVATE ${LIB_SHARED_C_FLAGS})
|
||||
target_compile_options(${LIB_SHARED} PRIVATE "${LIBSSH2_PICKY_C_FLAGS}" "${LIB_SHARED_C_FLAGS}")
|
||||
target_link_libraries(${LIB_SHARED} PRIVATE ${LIBSSH2_LIBS})
|
||||
set_target_properties(${LIB_SHARED} PROPERTIES
|
||||
PREFIX "" OUTPUT_NAME "libssh2" SOVERSION "${_libssh2_soversion}" VERSION "${_libssh2_libversion}"
|
||||
|
||||
@@ -76,6 +76,7 @@ target_include_directories(runner PRIVATE
|
||||
"${PROJECT_BINARY_DIR}/src"
|
||||
"${PROJECT_SOURCE_DIR}/src"
|
||||
"${PROJECT_SOURCE_DIR}/include")
|
||||
set_target_properties(runner PROPERTIES COMPILE_OPTIONS "${LIBSSH2_PICKY_C_FLAGS}")
|
||||
target_link_libraries(runner PRIVATE libssh2 ${LIBSSH2_LIBS})
|
||||
|
||||
foreach(_test IN LISTS DOCKER_TESTS STANDALONE_TESTS SSHD_TESTS)
|
||||
@@ -97,7 +98,7 @@ foreach(_test IN LISTS DOCKER_TESTS STANDALONE_TESTS SSHD_TESTS)
|
||||
"${PROJECT_BINARY_DIR}/src"
|
||||
"${PROJECT_SOURCE_DIR}/src"
|
||||
"${PROJECT_SOURCE_DIR}/include")
|
||||
set_target_properties(${_test} PROPERTIES UNITY_BUILD OFF)
|
||||
set_target_properties(${_test} PROPERTIES COMPILE_OPTIONS "${LIBSSH2_PICKY_C_FLAGS}" UNITY_BUILD OFF)
|
||||
target_link_libraries(${_test} PRIVATE runner ${_lib_for_tests} ${LIBSSH2_LIBS})
|
||||
|
||||
# build a single test with gcov
|
||||
|
||||
Reference in New Issue
Block a user