Cmake object linkage. Fix #7128: (cppcheck 1.70 doesn't report any warnings)
This commit is contained in:
parent
fe7d5cd242
commit
70c20515a9
|
@ -1,6 +1,8 @@
|
||||||
project(CppCheck)
|
project(CppCheck)
|
||||||
cmake_minimum_required(VERSION 2.8)
|
cmake_minimum_required(VERSION 2.8)
|
||||||
|
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
include(cmake/versions.cmake REQUIRED)
|
include(cmake/versions.cmake REQUIRED)
|
||||||
include(cmake/options.cmake REQUIRED)
|
include(cmake/options.cmake REQUIRED)
|
||||||
include(cmake/findDependencies.cmake REQUIRED)
|
include(cmake/findDependencies.cmake REQUIRED)
|
||||||
|
|
|
@ -1,23 +1,21 @@
|
||||||
include_directories(SYSTEM ${PROJECT_SOURCE_DIR}/externals/tinyxml/)
|
|
||||||
include_directories(${PROJECT_SOURCE_DIR}/lib/)
|
include_directories(${PROJECT_SOURCE_DIR}/lib/)
|
||||||
|
include_directories(SYSTEM ${PROJECT_SOURCE_DIR}/externals/tinyxml/)
|
||||||
|
|
||||||
file(GLOB hdrs "*.h")
|
file(GLOB hdrs "*.h")
|
||||||
file(GLOB srcs "*.cpp")
|
file(GLOB srcs "*.cpp")
|
||||||
file(GLOB mainfile "main.cpp")
|
file(GLOB mainfile "main.cpp")
|
||||||
list(REMOVE_ITEM srcs ${mainfile})
|
list(REMOVE_ITEM srcs ${mainfile})
|
||||||
|
|
||||||
link_libraries(${PROJECT_NAME} tinyxml)
|
add_library(cli_objs OBJECT ${hdrs} ${srcs})
|
||||||
|
add_executable(cppcheck ${hdrs} ${mainfile} $<TARGET_OBJECTS:cli_objs> $<TARGET_OBJECTS:lib_objs> $<TARGET_OBJECTS:tinyxml_objs>)
|
||||||
add_library(cli_lib OBJECT ${hdrs} ${srcs})
|
if (HAVE_RULES)
|
||||||
|
target_link_libraries(cppcheck pcre)
|
||||||
add_executable(cppcheck main.cpp
|
endif()
|
||||||
$<TARGET_OBJECTS:cli_lib>
|
|
||||||
)
|
|
||||||
|
|
||||||
install(TARGETS cppcheck
|
install(TARGETS cppcheck
|
||||||
RUNTIME DESTINATION bin
|
RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
|
||||||
COMPONENT applications)
|
COMPONENT applications)
|
||||||
|
|
||||||
install(FILES ${cfgs}
|
install(FILES ${cfgs}
|
||||||
DESTINATION share/${PROJECT_NAME}/
|
DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/${PROJECT_NAME}/
|
||||||
COMPONENT headers)
|
COMPONENT headers)
|
||||||
|
|
|
@ -35,7 +35,7 @@ endif()
|
||||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||||
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
|
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
|
||||||
if (NOT (GCC_VERSION VERSION_GREATER 4.7 OR GCC_VERSION VERSION_EQUAL 4.7))
|
if (NOT (GCC_VERSION VERSION_GREATER 4.7 OR GCC_VERSION VERSION_EQUAL 4.7))
|
||||||
message(FATAL_ERROR "${PROJECT_NAME} c++11 support requires g++ 4.7 or greater.")
|
message(FATAL_ERROR "${PROJECT_NAME} c++11 support requires g++ 4.7 or greater, but it is ${GCC_VERSION}")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wabi")
|
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wabi")
|
||||||
|
|
|
@ -35,10 +35,8 @@ else()
|
||||||
set(USE_MATCHCOMPILER_OPT ${USE_MATCHCOMPILER})
|
set(USE_MATCHCOMPILER_OPT ${USE_MATCHCOMPILER})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
|
|
||||||
option(BUILD_TESTS "Build tests" OFF)
|
option(BUILD_TESTS "Build tests" OFF)
|
||||||
option(BUILD_GUI "Build the qt application" OFF)
|
option(BUILD_GUI "Build the qt application" OFF)
|
||||||
option(BUILD_UTILS_TESTS "Build applications tests using the different modules" OFF)
|
|
||||||
|
|
||||||
option(HAVE_RULES "Usage of rules (needs PCRE library and headers)" OFF)
|
option(HAVE_RULES "Usage of rules (needs PCRE library and headers)" OFF)
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,6 @@
|
||||||
file(GLOB hdrs "*.h")
|
file(GLOB hdrs "*.h")
|
||||||
file(GLOB srcs "*.cpp")
|
file(GLOB srcs "*.cpp")
|
||||||
|
|
||||||
add_library(tinyxml ${srcs} ${hdrs})
|
add_library(tinyxml_objs OBJECT ${srcs} ${hdrs})
|
||||||
|
|
||||||
install(TARGETS tinyxml
|
|
||||||
RUNTIME DESTINATION bin COMPONENT libraries
|
|
||||||
LIBRARY DESTINATION lib PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE COMPONENT libraries
|
|
||||||
ARCHIVE DESTINATION lib COMPONENT libraries)
|
|
||||||
|
|
||||||
install(FILES ${hdrs}
|
|
||||||
DESTINATION include/${PROJECT_NAME}/
|
|
||||||
COMPONENT headers)
|
|
||||||
|
|
|
@ -10,9 +10,8 @@ if (BUILD_GUI)
|
||||||
add_definitions(-DQT_DEBUG)
|
add_definitions(-DQT_DEBUG)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
include_directories(SYSTEM ${PROJECT_SOURCE_DIR}/externals/tinyxml/)
|
|
||||||
include_directories(${PROJECT_SOURCE_DIR}/lib/)
|
include_directories(${PROJECT_SOURCE_DIR}/lib/)
|
||||||
|
include_directories(SYSTEM ${PROJECT_SOURCE_DIR}/externals/tinyxml/)
|
||||||
|
|
||||||
file(GLOB hdrs "*.h")
|
file(GLOB hdrs "*.h")
|
||||||
file(GLOB srcs "*.cpp")
|
file(GLOB srcs "*.cpp")
|
||||||
|
@ -22,12 +21,15 @@ if (BUILD_GUI)
|
||||||
QT4_ADD_RESOURCES(resources "gui.qrc")
|
QT4_ADD_RESOURCES(resources "gui.qrc")
|
||||||
QT4_ADD_TRANSLATION(qms ${tss})
|
QT4_ADD_TRANSLATION(qms ${tss})
|
||||||
|
|
||||||
link_libraries(${PROJECT_NAME} tinyxml ${QT_LIBRARIES})
|
add_executable(cppcheck-gui ${hdrs} ${srcs} ${uis_hdrs} ${resources} ${qms} $<TARGET_OBJECTS:lib_objs> $<TARGET_OBJECTS:tinyxml_objs>)
|
||||||
|
target_link_libraries(cppcheck-gui ${QT_LIBRARIES})
|
||||||
|
if (HAVE_RULES)
|
||||||
|
target_link_libraries(cppcheck-gui pcre)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_executable(cppcheck-gui ${hdrs} ${srcs} ${uis_hdrs} ${resources} ${qms})
|
|
||||||
|
|
||||||
install(TARGETS cppcheck-gui RUNTIME DESTINATION bin COMPONENT applications)
|
install(TARGETS cppcheck-gui RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR} COMPONENT applications)
|
||||||
install(FILES ${qms} DESTINATION bin COMPONENT applications)
|
install(FILES ${qms} DESTINATION ${CMAKE_INSTALL_FULL_BINDIR} COMPONENT applications)
|
||||||
|
|
||||||
set(CMAKE_AUTOMOC OFF)
|
set(CMAKE_AUTOMOC OFF)
|
||||||
|
|
||||||
|
|
|
@ -34,17 +34,5 @@ else()
|
||||||
set(srcs_lib ${srcs})
|
set(srcs_lib ${srcs})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_library(${PROJECT_NAME} ${srcs_lib} ${hdrs})
|
add_library(lib_objs OBJECT ${srcs_lib} ${hdrs})
|
||||||
|
|
||||||
if (HAVE_RULES)
|
|
||||||
target_link_libraries(${PROJECT_NAME} pcre)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
install(TARGETS ${PROJECT_NAME}
|
|
||||||
RUNTIME DESTINATION bin COMPONENT libraries
|
|
||||||
LIBRARY DESTINATION lib PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE COMPONENT libraries
|
|
||||||
ARCHIVE DESTINATION lib COMPONENT libraries)
|
|
||||||
|
|
||||||
install(FILES ${hdrs}
|
|
||||||
DESTINATION include/${PROJECT_NAME}/
|
|
||||||
COMPONENT headers)
|
|
||||||
|
|
|
@ -1,19 +1,15 @@
|
||||||
if (BUILD_TESTS)
|
if (BUILD_TESTS)
|
||||||
|
|
||||||
include_directories(
|
include_directories(${PROJECT_SOURCE_DIR}/lib/ ${PROJECT_SOURCE_DIR}/cli/)
|
||||||
${PROJECT_SOURCE_DIR}/lib/
|
include_directories(SYSTEM ${PROJECT_SOURCE_DIR}/externals/tinyxml)
|
||||||
${PROJECT_SOURCE_DIR}/cli/
|
|
||||||
${PROJECT_SOURCE_DIR}/externals/tinyxml
|
|
||||||
)
|
|
||||||
|
|
||||||
file(GLOB hdrs "*.h")
|
file(GLOB hdrs "*.h")
|
||||||
file(GLOB srcs "*.cpp")
|
file(GLOB srcs "*.cpp")
|
||||||
|
|
||||||
link_libraries(${PROJECT_NAME} tinyxml)
|
add_executable(testrunner ${hdrs} ${srcs} $<TARGET_OBJECTS:lib_objs> $<TARGET_OBJECTS:cli_objs> $<TARGET_OBJECTS:tinyxml_objs>)
|
||||||
|
if (HAVE_RULES)
|
||||||
add_executable(testrunner ${hdrs} ${srcs}
|
target_link_libraries(testunner pcre)
|
||||||
$<TARGET_OBJECTS:cli_lib>
|
endif()
|
||||||
)
|
|
||||||
|
|
||||||
add_custom_target(copy_cfg ALL
|
add_custom_target(copy_cfg ALL
|
||||||
COMMENT "Copying cfg files")
|
COMMENT "Copying cfg files")
|
||||||
|
|
Loading…
Reference in New Issue