- 
        Couldn't load subscription status. 
- Fork 1.5k
CMake cleanup #7658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
CMake cleanup #7658
Changes from 27 commits
a72f0e8
              7536500
              9524828
              aae3fa0
              e5f8f8c
              599a54e
              74f853f
              91afb23
              00c462a
              0e7f402
              ca5c192
              be40581
              e690613
              151d3d0
              0276fd8
              25d8719
              f95486d
              5416baa
              063a2f8
              5a27cca
              a4b579d
              c645209
              b8bd740
              f211acd
              5c47f9e
              8193d33
              56c3699
              872f922
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
|  | ||
| add_library(picojson INTERFACE) | ||
| target_externals_include_directories(picojson INTERFACE .) | ||
|  | 
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,11 +1,11 @@ | ||
| 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() | ||
| add_library(simplecpp ${srcs} ${hdrs}) | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be able to become a shared library. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It will if we set  There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then everything becomes a shared library which is not what we want. IMO the shared library stuff in the Windows build should be completely dropped. And I still thing this should not be real libraries since they are not actually reusable. | ||
| target_dll_compile_definitions(simplecpp EXPORT SIMPLECPP_EXPORT IMPORT SIMPLECPP_IMPORT) | ||
|  | ||
| if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||
| target_compile_options_safe(simplecpp_objs -Wno-zero-as-null-pointer-constant) | ||
| target_compile_options_safe(simplecpp -Wno-zero-as-null-pointer-constant) | ||
| endif() | ||
|  | ||
| target_externals_include_directories(simplecpp PUBLIC .) | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,24 +1,24 @@ | ||
| 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() | ||
| add_library(tinyxml2 ${srcs} ${hdrs}) | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be able to become a shared library. | ||
| target_dll_compile_definitions(tinyxml2 EXPORT TINYXML2_EXPORT IMPORT TINYXML2_IMPORT) | ||
|  | ||
| # TODO: needs to be fixed upstream | ||
| if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") | ||
| target_compile_options(tinyxml2_objs PRIVATE -Wno-suggest-attribute=format) | ||
| target_compile_options(tinyxml2_objs PRIVATE -Wno-useless-cast) | ||
| target_compile_options(tinyxml2 PRIVATE -Wno-suggest-attribute=format) | ||
| target_compile_options(tinyxml2 PRIVATE -Wno-useless-cast) | ||
| endif() | ||
| if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||
| target_compile_options_safe(tinyxml2_objs -Wno-implicit-fallthrough) | ||
| target_compile_options_safe(tinyxml2_objs -Wno-suggest-destructor-override) | ||
| target_compile_options_safe(tinyxml2_objs -Wno-zero-as-null-pointer-constant) | ||
| target_compile_options_safe(tinyxml2_objs -Wno-format-nonliteral) | ||
| target_compile_options_safe(tinyxml2_objs -Wno-inconsistent-missing-destructor-override) | ||
| target_compile_options_safe(tinyxml2 -Wno-implicit-fallthrough) | ||
| target_compile_options_safe(tinyxml2 -Wno-suggest-destructor-override) | ||
| target_compile_options_safe(tinyxml2 -Wno-zero-as-null-pointer-constant) | ||
| target_compile_options_safe(tinyxml2 -Wno-format-nonliteral) | ||
| target_compile_options_safe(tinyxml2 -Wno-inconsistent-missing-destructor-override) | ||
| endif() | ||
| if(CYGWIN) | ||
| target_compile_definitions(-D_LARGEFILE_SOURCE) # required for fseeko() and ftello() | ||
| endif() | ||
|  | ||
| target_externals_include_directories(tinyxml2 PUBLIC .) | ||
|  | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| file(GLOB hdrs "*.h") | ||
| file(GLOB srcs "*.cpp") | ||
|  | ||
| add_library(frontend_objs OBJECT ${hdrs} ${srcs}) | ||
| target_include_directories(frontend_objs PRIVATE ${PROJECT_SOURCE_DIR}/lib) | ||
| add_library(frontend ${hdrs} ${srcs}) | ||
| target_include_directories(frontend PUBLIC .) | ||
| target_link_libraries(frontend PRIVATE cppcheck-core) | 
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -6,10 +6,6 @@ qt_wrap_cpp(test-resultstree_SRC | |
| ${CMAKE_SOURCE_DIR}/gui/threadhandler.h | ||
| ${CMAKE_SOURCE_DIR}/gui/threadresult.h | ||
| ) | ||
| if(USE_BUNDLED_TINYXML2) | ||
| list(APPEND test-resultstree_SRC $<TARGET_OBJECTS:tinyxml2_objs>) | ||
| endif() | ||
| list(APPEND test-resultstree_SRC $<TARGET_OBJECTS:simplecpp_objs> $<TARGET_OBJECTS:cppcheck-core>) | ||
| add_custom_target(build-resultstree-deps SOURCES ${test-resultstree_SRC}) | ||
| add_dependencies(gui-build-deps build-resultstree-deps) | ||
| add_executable(test-resultstree | ||
|  | @@ -21,22 +17,14 @@ add_executable(test-resultstree | |
| ${CMAKE_SOURCE_DIR}/gui/report.cpp | ||
| ${CMAKE_SOURCE_DIR}/gui/xmlreportv2.cpp | ||
| ) | ||
| target_include_directories(test-resultstree PRIVATE ${CMAKE_SOURCE_DIR}/gui ${CMAKE_SOURCE_DIR}/lib) | ||
| target_externals_include_directories(test-resultstree PRIVATE ${CMAKE_SOURCE_DIR}/externals/simplecpp) | ||
| if(USE_BUNDLED_TINYXML2) | ||
| target_externals_include_directories(test-resultstree PRIVATE ${PROJECT_SOURCE_DIR}/externals/tinyxml2/) | ||
| else() | ||
| target_include_directories(test-resultstree SYSTEM PRIVATE ${tinyxml2_INCLUDE_DIRS}) | ||
| endif() | ||
| target_include_directories(test-resultstree PRIVATE ${CMAKE_SOURCE_DIR}/gui) | ||
| target_link_libraries(test-resultstree cppcheck-core simplecpp tinyxml2) | ||
| if (HAVE_RULES) | ||
| target_link_libraries(test-resultstree ${PCRE_LIBRARY}) | ||
| target_include_directories(test-resultstree SYSTEM PRIVATE ${PCRE_INCLUDE}) | ||
| endif() | ||
| target_compile_definitions(test-resultstree PRIVATE SRCDIR="${CMAKE_CURRENT_SOURCE_DIR}") | ||
| target_link_libraries(test-resultstree ${QT_CORE_LIB} ${QT_GUI_LIB} ${QT_WIDGETS_LIB} ${QT_TEST_LIB}) | ||
| if(tinyxml2_FOUND AND NOT USE_BUNDLED_TINYXML2) | ||
| target_link_libraries(test-resultstree ${tinyxml2_LIBRARIES}) | ||
| endif() | ||
|  | ||
| if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||
| if(QT_VERSION VERSION_GREATER_EQUAL "6.9.0") | ||
|  | @@ -52,6 +40,12 @@ elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") | |
| target_compile_options_safe(test-resultstree -Wno-suggest-attribute=noreturn) | ||
| endif() | ||
|  | ||
| if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") | ||
| # caused by mocks | ||
| target_compile_options_safe(test-resultstree -Wno-suggest-attribute=noreturn) | ||
| endif() | ||
|  | ||
|  | ||
|          | ||
| if (REGISTER_GUI_TESTS) | ||
| # TODO: might crash - see #13223 | ||
| #add_test(NAME test-resultstree COMMAND $<TARGET_FILE:test-resultstree> -platform offscreen) | ||
|  | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like we will do CLI stuff in CMake even if the CLI is disabled and that seems to defeat the purpose to disable it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its a dependency for dmake which seems required even if CLI is disabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In latest HEAD I am able to build the GUI without the building CLI. Will this work still?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, because dmake requires
FileListerfrom cli library, and dmake is always built so its always needed.The previous hacks just cause a long chain of other problems and hacks. It also breaks the modularity of the components in cppcheck.
This can be solved by either moving
FileListerinto cppcheck-core or making a seperate library forFileLister. I figure this could be handled by a later PR to minimize the changes in this PR.