added CMake option `BUILD_CORE_DLL` to build lib as `cppcheck-core.dll` with Visual Studio (#4733)
This commit is contained in:
parent
c3aa0940be
commit
a0b1285f4a
|
@ -33,7 +33,7 @@ jobs:
|
|||
- name: Prepare CMake dependencies
|
||||
run: |
|
||||
# make sure the precompiled headers exist
|
||||
#make -C cmake.output lib/CMakeFiles/lib_objs.dir/cmake_pch.hxx.cxx
|
||||
#make -C cmake.output lib/CMakeFiles/cppcheck-core.dir/cmake_pch.hxx.cxx
|
||||
#make -C cmake.output test/CMakeFiles/testrunner.dir/cmake_pch.hxx.cxx
|
||||
# make sure the auto-generated GUI sources exist
|
||||
make -C cmake.output autogen
|
||||
|
|
|
@ -58,7 +58,7 @@ jobs:
|
|||
- name: Generate dependencies
|
||||
run: |
|
||||
# make sure the precompiled headers exist
|
||||
make -C cmake.output lib/CMakeFiles/lib_objs.dir/cmake_pch.hxx.cxx
|
||||
make -C cmake.output lib/CMakeFiles/cppcheck-core.dir/cmake_pch.hxx.cxx
|
||||
make -C cmake.output test/CMakeFiles/testrunner.dir/cmake_pch.hxx.cxx
|
||||
# make sure auto-generated GUI files exist
|
||||
make -C cmake.output autogen
|
||||
|
@ -81,7 +81,7 @@ jobs:
|
|||
- name: Generate dependencies (no test)
|
||||
run: |
|
||||
# make sure the precompiled headers exist
|
||||
make -C cmake.output.notest lib/CMakeFiles/lib_objs.dir/cmake_pch.hxx.cxx
|
||||
make -C cmake.output.notest lib/CMakeFiles/cppcheck-core.dir/cmake_pch.hxx.cxx
|
||||
# make sure auto-generated GUI files exist
|
||||
make -C cmake.output.notest autogen
|
||||
make -C cmake.output.notest gui-build-deps
|
||||
|
@ -106,7 +106,7 @@ jobs:
|
|||
- name: Generate dependencies (corpus)
|
||||
run: |
|
||||
# make sure the precompiled headers exist
|
||||
make -C cmake.output.notest lib/CMakeFiles/lib_objs.dir/cmake_pch.hxx.cxx
|
||||
make -C cmake.output.notest lib/CMakeFiles/cppcheck-core.dir/cmake_pch.hxx.cxx
|
||||
# make sure auto-generated GUI files exist
|
||||
make -C cmake.output.corpus autogen
|
||||
make -C cmake.output.corpus gui-build-deps
|
||||
|
|
|
@ -11,15 +11,25 @@ else()
|
|||
target_include_directories(cli_objs SYSTEM PRIVATE ${tinyxml2_INCLUDE_DIRS})
|
||||
endif()
|
||||
target_include_directories(cli_objs PRIVATE ${PROJECT_SOURCE_DIR}/externals/simplecpp/)
|
||||
if (BUILD_CORE_DLL)
|
||||
target_compile_definitions(cli_objs PRIVATE CPPCHECKLIB_IMPORT TINYXML2_IMPORT)
|
||||
endif()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14)
|
||||
# false positive warning in up to Clang 13 - caused by FD_ZERO macro
|
||||
set_source_files_properties(processexecutor.cpp PROPERTIES COMPILE_FLAGS -Wno-reserved-identifier)
|
||||
endif()
|
||||
|
||||
list(APPEND cppcheck_SOURCES ${hdrs} ${mainfile} $<TARGET_OBJECTS:cli_objs> $<TARGET_OBJECTS:lib_objs> $<TARGET_OBJECTS:simplecpp_objs>)
|
||||
if(USE_BUNDLED_TINYXML2)
|
||||
list(APPEND cppcheck_SOURCES $<TARGET_OBJECTS:tinyxml2_objs>)
|
||||
list(APPEND cppcheck_SOURCES ${hdrs} ${mainfile} $<TARGET_OBJECTS:cli_objs>)
|
||||
if (NOT BUILD_CORE_DLL)
|
||||
list(APPEND cppcheck_SOURCES $<TARGET_OBJECTS:cppcheck-core>)
|
||||
list(APPEND cppcheck_SOURCES $<TARGET_OBJECTS:simplecpp_objs>)
|
||||
if(USE_BUNDLED_TINYXML2)
|
||||
list(APPEND cppcheck_SOURCES $<TARGET_OBJECTS:tinyxml2_objs>)
|
||||
endif()
|
||||
endif()
|
||||
if (WIN32)
|
||||
list(APPEND cppcheck_SOURCES version.rc)
|
||||
endif()
|
||||
|
||||
add_executable(cppcheck ${cppcheck_SOURCES})
|
||||
|
@ -44,6 +54,9 @@ if(tinyxml2_FOUND AND NOT USE_BUNDLED_TINYXML2)
|
|||
target_link_libraries(cppcheck ${tinyxml2_LIBRARIES})
|
||||
endif()
|
||||
target_link_libraries(cppcheck ${CMAKE_THREAD_LIBS_INIT})
|
||||
if (BUILD_CORE_DLL)
|
||||
target_link_libraries(cppcheck cppcheck-core)
|
||||
endif()
|
||||
|
||||
add_dependencies(cppcheck copy_cfg)
|
||||
add_dependencies(cppcheck copy_addons)
|
||||
|
|
|
@ -4,8 +4,6 @@ if (MSVC)
|
|||
add_definitions(-DDEBUG)
|
||||
endif()
|
||||
|
||||
#add_definitions(-DCPPCHECKLIB_IMPORT)
|
||||
#add_definitions(-DTINYXML2_IMPORT)
|
||||
add_definitions(-DWIN32)
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||
add_definitions(-DWIN32_LEAN_MEAN)
|
||||
|
|
|
@ -31,6 +31,10 @@ else()
|
|||
set(USE_MATCHCOMPILER_OPT ${USE_MATCHCOMPILER})
|
||||
endif()
|
||||
|
||||
option(BUILD_CORE_DLL "Build lib as cppcheck-core.dll with Visual Studio" OFF)
|
||||
if (NOT MSVC)
|
||||
set(BUILD_CORE_DLL OFF)
|
||||
endif()
|
||||
option(BUILD_TESTS "Build tests" OFF)
|
||||
option(REGISTER_TESTS "Register tests in CTest" ON)
|
||||
option(ENABLE_CHECK_INTERNAL "Enable internal checks" OFF)
|
||||
|
@ -42,6 +46,9 @@ option(USE_QT6 "Prefer Qt6 when available"
|
|||
|
||||
option(HAVE_RULES "Usage of rules (needs PCRE library and headers)" OFF)
|
||||
option(USE_BUNDLED_TINYXML2 "Usage of bundled tinyxml2 library" ON)
|
||||
if (BUILD_CORE_DLL)
|
||||
set(USE_BUNDLED_TINYXML2 ON)
|
||||
endif()
|
||||
option(CPPCHK_GLIBCXX_DEBUG "Usage of STL debug checks in Debug build" ON)
|
||||
option(USE_THREADS "Usage of threads instead of fork() for -j" OFF)
|
||||
option(USE_BOOST "Usage of Boost" OFF)
|
||||
|
|
|
@ -39,6 +39,7 @@ else()
|
|||
message( STATUS "BUILD_SHARED_LIBS = ${BUILD_SHARED_LIBS}" )
|
||||
endif(NOT DEFINED BUILD_SHARED_LIBS)
|
||||
message( STATUS "LIBXML2_XMLLINT_EXECUTABLE = ${LIBXML2_XMLLINT_EXECUTABLE}" )
|
||||
message( STATUS "BUILD_CORE_DLL = ${BUILD_CORE_DLL}" )
|
||||
message( STATUS "BUILD_TESTS = ${BUILD_TESTS}" )
|
||||
if(BUILD_TESTS)
|
||||
message( STATUS "REGISTER_TESTS = ${REGISTER_TESTS}" )
|
||||
|
|
|
@ -2,6 +2,10 @@ file(GLOB hdrs "*.h")
|
|||
file(GLOB srcs "*.cpp")
|
||||
|
||||
add_library(simplecpp_objs OBJECT ${srcs} ${hdrs})
|
||||
if (BUILD_CORE_DLL)
|
||||
target_compile_definitions(simplecpp_objs PRIVATE SIMPLECPP_EXPORT)
|
||||
endif()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
target_compile_options_safe(simplecpp_objs -Wno-zero-as-null-pointer-constant)
|
||||
endif()
|
||||
|
|
|
@ -2,6 +2,9 @@ file(GLOB hdrs "*.h")
|
|||
file(GLOB srcs "*.cpp")
|
||||
|
||||
add_library(tinyxml2_objs OBJECT ${srcs} ${hdrs})
|
||||
if (BUILD_CORE_DLL)
|
||||
target_compile_definitions(tinyxml2_objs PRIVATE TINYXML2_EXPORT)
|
||||
endif()
|
||||
|
||||
# TODO: needs to be fixed upstream
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
|
|
|
@ -28,9 +28,12 @@ CheckOptions:
|
|||
list(APPEND cppcheck-gui-deps ${hdrs} ${uis_hdrs} ${resources} ${qms})
|
||||
add_custom_target(gui-build-deps SOURCES ${cppcheck-gui-deps})
|
||||
|
||||
list(APPEND cppcheck-gui_SOURCES ${srcs} $<TARGET_OBJECTS:lib_objs> $<TARGET_OBJECTS:simplecpp_objs>)
|
||||
if(USE_BUNDLED_TINYXML2)
|
||||
list(APPEND cppcheck-gui_SOURCES $<TARGET_OBJECTS:tinyxml2_objs>)
|
||||
list(APPEND cppcheck-gui_SOURCES ${srcs})
|
||||
if (NOT BUILD_CORE_DLL)
|
||||
list(APPEND cppcheck-gui_SOURCES $<TARGET_OBJECTS:cppcheck-core> $<TARGET_OBJECTS:simplecpp_objs>)
|
||||
if(USE_BUNDLED_TINYXML2)
|
||||
list(APPEND cppcheck-gui_SOURCES $<TARGET_OBJECTS:tinyxml2_objs>)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_executable(cppcheck-gui ${cppcheck-gui-deps} ${cppcheck-gui_SOURCES})
|
||||
|
@ -52,6 +55,10 @@ CheckOptions:
|
|||
target_compile_definitions (cppcheck-gui PRIVATE HAVE_QCHART)
|
||||
target_link_libraries(cppcheck-gui ${QT_CHARTS_LIB})
|
||||
endif()
|
||||
if (BUILD_CORE_DLL)
|
||||
target_compile_definitions(cppcheck-gui PRIVATE CPPCHECKLIB_IMPORT TINYXML2_IMPORT)
|
||||
target_link_libraries(cppcheck-gui cppcheck-core)
|
||||
endif()
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
# Q_UNUSED() in generated code
|
||||
target_compile_options_safe(cppcheck-gui -Wno-extra-semi-stmt)
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
qt_wrap_cpp(test-xmlreportv2_SRC testxmlreportv2.h)
|
||||
add_custom_target(build-xmlreportv2-deps SOURCES ${test-xmlreportv2_SRC})
|
||||
add_dependencies(gui-build-deps build-xmlreportv2-deps)
|
||||
if(USE_BUNDLED_TINYXML2)
|
||||
list(APPEND test-xmlreportv2_SRC $<TARGET_OBJECTS:tinyxml2_objs>)
|
||||
if (NOT BUILD_CORE_DLL)
|
||||
list(APPEND test-xmlreportv2_SRC $<TARGET_OBJECTS:cppcheck-core> $<TARGET_OBJECTS:simplecpp_objs>)
|
||||
if(USE_BUNDLED_TINYXML2)
|
||||
list(APPEND test-xmlreportv2_SRC $<TARGET_OBJECTS:tinyxml2_objs>)
|
||||
endif()
|
||||
endif()
|
||||
add_executable(test-xmlreportv2
|
||||
${test-xmlreportv2_SRC}
|
||||
|
@ -11,8 +14,6 @@ add_executable(test-xmlreportv2
|
|||
${CMAKE_SOURCE_DIR}/gui/report.cpp
|
||||
${CMAKE_SOURCE_DIR}/gui/xmlreport.cpp
|
||||
${CMAKE_SOURCE_DIR}/gui/xmlreportv2.cpp
|
||||
$<TARGET_OBJECTS:lib_objs>
|
||||
$<TARGET_OBJECTS:simplecpp_objs>
|
||||
)
|
||||
target_include_directories(test-xmlreportv2 PRIVATE ${CMAKE_SOURCE_DIR}/gui ${CMAKE_SOURCE_DIR}/lib)
|
||||
target_compile_definitions(test-xmlreportv2 PRIVATE SRCDIR="${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
@ -23,3 +24,7 @@ endif()
|
|||
if(tinyxml2_FOUND AND NOT USE_BUNDLED_TINYXML2)
|
||||
target_link_libraries(test-xmlreportv2 ${tinyxml2_LIBRARIES})
|
||||
endif()
|
||||
if (BUILD_CORE_DLL)
|
||||
target_compile_definitions(test-xmlreportv2 PRIVATE CPPCHECKLIB_IMPORT TINYXML2_IMPORT)
|
||||
target_link_libraries(test-xmlreportv2 cppcheck-core)
|
||||
endif()
|
||||
|
|
|
@ -32,23 +32,29 @@ else()
|
|||
set(srcs_lib ${srcs})
|
||||
endif()
|
||||
|
||||
add_library(lib_objs OBJECT ${srcs_lib} ${hdrs})
|
||||
if(USE_BUNDLED_TINYXML2)
|
||||
target_include_directories(lib_objs PRIVATE ${PROJECT_SOURCE_DIR}/externals/tinyxml2/)
|
||||
if (BUILD_CORE_DLL)
|
||||
add_library(cppcheck-core SHARED ${srcs_lib} ${hdrs} $<TARGET_OBJECTS:tinyxml2_objs> $<TARGET_OBJECTS:simplecpp_objs> version.rc)
|
||||
target_compile_definitions(cppcheck-core PRIVATE CPPCHECKLIB_EXPORT TINYXML2_EXPORT SIMPLECPP_EXPORT)
|
||||
else()
|
||||
target_include_directories(lib_objs SYSTEM PRIVATE ${tinyxml2_INCLUDE_DIRS})
|
||||
add_library(cppcheck-core OBJECT ${srcs_lib} ${hdrs})
|
||||
endif()
|
||||
target_include_directories(lib_objs PRIVATE ${PROJECT_SOURCE_DIR}/externals/picojson/)
|
||||
target_include_directories(lib_objs PRIVATE ${PROJECT_SOURCE_DIR}/externals/simplecpp/)
|
||||
target_include_directories(cppcheck-core PRIVATE ${PROJECT_SOURCE_DIR}/externals/)
|
||||
if(USE_BUNDLED_TINYXML2)
|
||||
target_include_directories(cppcheck-core PRIVATE ${PROJECT_SOURCE_DIR}/externals/tinyxml2/)
|
||||
else()
|
||||
target_include_directories(cppcheck-core SYSTEM PRIVATE ${tinyxml2_INCLUDE_DIRS})
|
||||
endif()
|
||||
target_include_directories(cppcheck-core PRIVATE ${PROJECT_SOURCE_DIR}/externals/picojson/)
|
||||
target_include_directories(cppcheck-core PRIVATE ${PROJECT_SOURCE_DIR}/externals/simplecpp/)
|
||||
if (HAVE_RULES)
|
||||
target_include_directories(lib_objs SYSTEM PRIVATE ${PCRE_INCLUDE})
|
||||
target_include_directories(cppcheck-core SYSTEM PRIVATE ${PCRE_INCLUDE})
|
||||
endif()
|
||||
if (Boost_FOUND)
|
||||
target_include_directories(lib_objs SYSTEM PRIVATE ${Boost_INCLUDE_DIRS})
|
||||
target_include_directories(cppcheck-core SYSTEM PRIVATE ${Boost_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
if (NOT CMAKE_DISABLE_PRECOMPILE_HEADERS)
|
||||
target_precompile_headers(lib_objs PRIVATE precompiled.h)
|
||||
target_precompile_headers(cppcheck-core PRIVATE precompiled.h)
|
||||
endif()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
|
|
|
@ -9,7 +9,7 @@ if (ENABLE_OSS_FUZZ AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
|||
add_executable(fuzz-client EXCLUDE_FROM_ALL
|
||||
${fuzz-client_SRC}
|
||||
$<TARGET_OBJECTS:simplecpp_objs>
|
||||
$<TARGET_OBJECTS:lib_objs>)
|
||||
$<TARGET_OBJECTS:cppcheck-core>)
|
||||
target_include_directories(fuzz-client PRIVATE ${CMAKE_SOURCE_DIR}/lib ${CMAKE_SOURCE_DIR}/externals/simplecpp ${CMAKE_SOURCE_DIR}/externals)
|
||||
if(USE_BUNDLED_TINYXML2)
|
||||
target_include_directories(fuzz-client PRIVATE ${CMAKE_SOURCE_DIR}/externals/tinyxml2/)
|
||||
|
|
|
@ -3,3 +3,4 @@ release notes for cppcheck-2.10
|
|||
- the deprecated Makefile option SRCDIR is no longer accepted
|
||||
- if the file provided via "--file-list" cannot be opened it will now error out
|
||||
- add command-line option "--disable=<id>" to individually disable checks
|
||||
- added CMake option BUILD_CORE_DLL to build lib as cppcheck-core.dll with Visual Studio
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
if (BUILD_TESTS)
|
||||
file(GLOB hdrs "*.h")
|
||||
file(GLOB srcs "*.cpp")
|
||||
list(APPEND testrunner_SOURCES ${hdrs} ${srcs} $<TARGET_OBJECTS:lib_objs> $<TARGET_OBJECTS:cli_objs> $<TARGET_OBJECTS:simplecpp_objs>)
|
||||
if(USE_BUNDLED_TINYXML2)
|
||||
list(APPEND testrunner_SOURCES $<TARGET_OBJECTS:tinyxml2_objs>)
|
||||
list(APPEND testrunner_SOURCES ${hdrs} ${srcs} $<TARGET_OBJECTS:cli_objs>)
|
||||
if (NOT BUILD_CORE_DLL)
|
||||
list(APPEND testrunner_SOURCES $<TARGET_OBJECTS:cppcheck-core> $<TARGET_OBJECTS:simplecpp_objs>)
|
||||
if(USE_BUNDLED_TINYXML2)
|
||||
list(APPEND testrunner_SOURCES $<TARGET_OBJECTS:tinyxml2_objs>)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_executable(testrunner ${testrunner_SOURCES})
|
||||
|
@ -28,6 +31,10 @@ if (BUILD_TESTS)
|
|||
target_link_libraries(testrunner ${tinyxml2_LIBRARIES})
|
||||
endif()
|
||||
target_link_libraries(testrunner ${CMAKE_THREAD_LIBS_INIT})
|
||||
if (BUILD_CORE_DLL)
|
||||
target_compile_definitions(testrunner PRIVATE CPPCHECKLIB_IMPORT SIMPLECPP_IMPORT)
|
||||
target_link_libraries(testrunner cppcheck-core)
|
||||
endif()
|
||||
|
||||
if (NOT CMAKE_DISABLE_PRECOMPILE_HEADERS)
|
||||
target_precompile_headers(testrunner PRIVATE precompiled.h)
|
||||
|
|
Loading…
Reference in New Issue