cmake
Some checks failed
C/C++ CI / build (push) Has been cancelled

This commit is contained in:
LiXiaoqi 2024-11-12 10:24:19 +08:00
parent 4abb6f8da5
commit 7885fdd002

View File

@ -5,10 +5,11 @@ enable_testing()
project(minmea) project(minmea)
find_package(Threads REQUIRED) # Workaround for https://github.com/libcheck/check/issues/48#issuecomment-322965461 find_package(Threads REQUIRED) # Workaround for https://github.com/libcheck/check/issues/48#issuecomment-322965461
find_package(PkgConfig) #]]
pkg_check_modules(CHECK REQUIRED check) # find_package(PkgConfig)
link_directories(${CHECK_LIBRARY_DIRS}) # pkg_check_modules(CHECK REQUIRED check)
# link_directories(${CHECK_LIBRARY_DIRS})
#]]
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -Wextra -Werror -std=c99") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -Wextra -Werror -std=c99")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_POSIX_C_SOURCE=199309L -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_DARWIN_C_SOURCE") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_POSIX_C_SOURCE=199309L -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_DARWIN_C_SOURCE")
@ -18,25 +19,25 @@ add_library(minmea ${minmea_SRCS})
add_executable(example example.c) add_executable(example example.c)
target_link_libraries(example minmea) target_link_libraries(example minmea)
add_executable(tests tests.c) # add_executable(tests tests.c)
target_link_libraries(tests minmea ${CHECK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) # target_link_libraries(tests minmea ${CHECK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
target_include_directories(tests PUBLIC ${CHECK_INCLUDE_DIRS}) # target_include_directories(tests PUBLIC ${CHECK_INCLUDE_DIRS})
target_compile_options(tests PUBLIC ${CHECK_CFLAGS_OTHER}) # target_compile_options(tests PUBLIC ${CHECK_CFLAGS_OTHER})
add_test(NAME tests COMMAND $<TARGET_FILE:tests>) # add_test(NAME tests COMMAND $<TARGET_FILE:tests>)
list(APPEND CMAKE_CTEST_ARGUMENTS "--output-on-failure") # list(APPEND CMAKE_CTEST_ARGUMENTS "--output-on-failure")
find_program(SCAN_FOUND scan-build) # find_program(SCAN_FOUND scan-build)
if (SCAN_FOUND) # if (SCAN_FOUND)
add_test( # add_test(
NAME clang_static_analysis # NAME clang_static_analysis
COMMAND scan-build make # COMMAND scan-build make
WORKING_DIRECTORY ${CMAKE_BINARY_DIR} # WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
) # )
else() # else()
MESSAGE(STATUS "scan-build not found, not scanning code") # MESSAGE(STATUS "scan-build not found, not scanning code")
endif() # endif()
include(GNUInstallDirs) include(GNUInstallDirs)