Skip to content

Commit

Permalink
Merge f456f5f into 77cd1f2
Browse files Browse the repository at this point in the history
  • Loading branch information
agarny committed Apr 21, 2019
2 parents 77cd1f2 + f456f5f commit e508ed2
Show file tree
Hide file tree
Showing 324 changed files with 8,967 additions and 6,773 deletions.
40 changes: 40 additions & 0 deletions .clang-tidy
@@ -0,0 +1,40 @@
# Note: the full list of Clang-Tidy checks can be found at
# https://clang.llvm.org/extra/clang-tidy/checks/list.html...

---
Checks: >-
-*,
bugprone-*,
cert-*,
cppcoreguidelines-*,
-cppcoreguidelines-avoid-c-arrays,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-owning-memory,
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
-cppcoreguidelines-pro-bounds-constant-array-index,
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
-cppcoreguidelines-pro-type-const-cast,
-cppcoreguidelines-pro-type-reinterpret-cast,
-cppcoreguidelines-pro-type-static-cast-downcast,
-cppcoreguidelines-pro-type-vararg,
fuchsia-*,
-fuchsia-default-arguments,
-fuchsia-overloaded-operator,
google-*,
-google-default-arguments,
hicpp-*,
-hicpp-no-array-decay,
-hicpp-signed-bitwise,
-hicpp-vararg,
llvm-*,
-llvm-include-order,
misc-*,
modernize-*,
-modernize-pass-by-value,
performance-*,
readability-*,
-readability-isolate-declaration,
-readability-magic-numbers
WarningsAsErrors: >-
*
...
104 changes: 49 additions & 55 deletions CMakeLists.txt
Expand Up @@ -6,6 +6,8 @@ project(OpenCOR)

# Our options

option(ENABLE_CLANG_TIDY "Enable the use of Clang-Tidy" OFF)

option(ENABLE_SAMPLE_PLUGINS "Enable the sample plugins to be built" OFF)
option(ENABLE_TEST_PLUGINS "Enable the test plugins to be built" OFF)
option(ENABLE_TESTS "Enable the tests to be built" OFF)
Expand Down Expand Up @@ -51,7 +53,7 @@ if(WIN32)
if( NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC"
OR NOT "${CMAKE_CXX_COMPILER_VERSION_MAJOR}" STREQUAL "19"
OR NOT "${CMAKE_CXX_COMPILER_VERSION_MINOR}" STREQUAL "16")
message(FATAL_ERROR "${CMAKE_PROJECT_NAME} can only be built using MSVC 2017 Update 9 on Windows...")
message(FATAL_ERROR "${CMAKE_PROJECT_NAME} can only be built using MSVC 2017 on Windows...")
endif()
elseif(APPLE)
if( NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"
Expand Down Expand Up @@ -165,6 +167,31 @@ if(NOT WIN32 AND NOT APPLE)
endif()
endif()

# Look and get ready for Clang-Tidy
# Note: we don't want Clang-Tidy to analyse files in our build directory.
# Indeed, some files generated by Qt may result in Clang-Tidy warnings
# that have nothing to do with OpenCOR. We therefore ignore them by
# creating a special .clang-tidy file in our build directory. That file
# disables all checks but one, which is necessary for Clang-Tidy to work.
# That check is for boost-use-to-string, which is as if we didn't have
# any checks since we don't use Boost ...

if(ENABLE_CLANG_TIDY)
find_program(CLANG_TIDY clang-tidy)

if(CLANG_TIDY)
file(WRITE "${PROJECT_BUILD_DIR}/.clang-tidy"
"---
Checks: >-
-*,
boost-use-to-string
...
")
else()
message(FATAL_ERROR "Clang-Tidy could not be found...")
endif()
endif()

# Make sure that clcache/ccache gets used, if available

if(WIN32)
Expand All @@ -190,27 +217,21 @@ else()
endif()
endif()

# Prevent long command lines on Windows

if(WIN32)
set(CMAKE_C_USE_RESPONSE_FILE_FOR_OBJECTS TRUE)
set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_OBJECTS TRUE)

if("${CMAKE_GENERATOR}" STREQUAL "Ninja")
set(CMAKE_NINJA_FORCE_RESPONSE_FILE TRUE)
endif()
endif()

# Keep track of some basic information about Qt, after making sure that we have
# the version of Qt that we need

find_package(Qt5Core REQUIRED)

set(QT_VERSION ${Qt5Core_VERSION})
set(QT_VERSION_MAJOR ${Qt5Core_VERSION_MAJOR})
set(QT_VERSION_MINOR ${Qt5Core_VERSION_MINOR})

set(REQUIRED_QT_LTS_VERSION_MAJOR 5)
set(REQUIRED_QT_LTS_VERSION_MINOR 12)

if(QT_VERSION VERSION_LESS 5.9.2)
message(FATAL_ERROR "${CMAKE_PROJECT_NAME} can only be built using Qt 5.9.2 and later...")
if( NOT ${QT_VERSION_MAJOR} EQUAL ${REQUIRED_QT_LTS_VERSION_MAJOR}
OR NOT ${QT_VERSION_MINOR} EQUAL ${REQUIRED_QT_LTS_VERSION_MINOR})
message(FATAL_ERROR "${CMAKE_PROJECT_NAME} can only be built using Qt ${REQUIRED_QT_LTS_VERSION_MAJOR}.${REQUIRED_QT_LTS_VERSION_MINOR}.x LTS...")
endif()

set(QT_DIR ${_qt5Core_install_prefix})
Expand All @@ -222,6 +243,10 @@ get_target_property(QMAKE ${Qt5Core_QMAKE_EXECUTABLE} IMPORTED_LOCATION)

set(QMAKE_COMMAND ${QMAKE} -Wnone)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

# Determine our platform directory

if(WIN32)
Expand Down Expand Up @@ -556,7 +581,7 @@ endif()

# Show what we are about to build

message("${BUILD_INFORMATION} using Qt ${QT_VERSION}...")
message("${BUILD_INFORMATION} using Qt ${QT_VERSION} LTS...")

# Keep track of our source and build directories (needed to run our tests)

Expand Down Expand Up @@ -634,25 +659,6 @@ set(SOURCES
src/plugins/windowinterface.cpp
)

set(HEADERS_MOC
src/checkforupdatesdialog.h
src/generalpreferenceswidget.h
src/mainwindow.h
src/pluginsdialog.h
src/preferencesdialog.h
src/splashscreenwindow.h

src/misc/cliutils.h
src/misc/guiapplication.h
src/misc/guiutils.h

src/plugins/datastoreinterface.h
src/plugins/plugin.h
src/plugins/pluginmanager.h
src/plugins/preferencesinterface.h
src/plugins/solverinterface.h
)

set(UIS
src/checkforupdatesdialog.ui
src/generalpreferenceswidget.ui
Expand Down Expand Up @@ -690,15 +696,6 @@ if(WIN32)
src/windows/main.cpp
)

set(WINDOWS_CLI_HEADERS_MOC
src/misc/cliutils.h

src/plugins/datastoreinterface.h
src/plugins/plugin.h
src/plugins/pluginmanager.h
src/plugins/solverinterface.h
)

set(WINDOWS_CLI_RESOURCES
${COMMON_QRC_FILENAME}
)
Expand All @@ -718,9 +715,9 @@ include_directories(
)

# Update the translation (.ts) files and generate the language (.qm) files
# that will later on be embedded in the OpenCOR executable as resources
# that will later be embedded in the OpenCOR executable as resources

update_language_files(${CMAKE_PROJECT_NAME} ${SOURCES} ${HEADERS_MOC} ${UIS})
update_language_files(${CMAKE_PROJECT_NAME} ${SOURCES} ${UIS})

# Third-party library that must be directly embedded in the GUI version of
# OpenCOR
Expand Down Expand Up @@ -808,6 +805,8 @@ if(ENABLE_TESTS)
LINK_FLAGS "${LINK_FLAGS_PROPERTIES}"
)

configure_clang_and_clang_tidy(${RUNTESTS_NAME})

target_link_libraries(${RUNTESTS_NAME}
Qt5::Core
Qt5::Network
Expand All @@ -831,7 +830,7 @@ if(ENABLE_TESTS)
endif()
endif()

# Specify a target to help us build certain plugins (e.g. the Python plugin)
# Specify a target to help us build certain plugins (e.g. our Python plugin)

set(PROJECT_BUILD_TARGET ${PROJECT_NAME}Build)

Expand Down Expand Up @@ -956,11 +955,8 @@ foreach(PLUGIN ${PLUGINS})
endif()

include_directories(${CMAKE_SOURCE_DIR}/${PLUGIN_DIR}/src)
include_directories(${PROJECT_BUILD_DIR}/${PLUGIN_DIR})
endforeach()

set(CMAKE_INCLUDE_CURRENT_DIR ON)

foreach(PLUGIN ${PLUGINS})
add_subdirectory(src/plugins/${PLUGIN})
endforeach()
Expand All @@ -978,8 +974,6 @@ build_documentation(developer)

# Build the GUI version of OpenCOR

qt5_wrap_cpp(SOURCES_MOC ${HEADERS_MOC})
qt5_wrap_ui(SOURCES_UIS ${UIS})
qt5_add_resources(SOURCES_RCS ${RESOURCES})

if(APPLE)
Expand All @@ -990,8 +984,6 @@ endif()

add_executable(${CMAKE_PROJECT_NAME} WIN32 MACOSX_BUNDLE
${SOURCES}
${SOURCES_MOC}
${SOURCES_UIS}
${SOURCES_RCS}
)

Expand All @@ -1002,6 +994,8 @@ set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES
LINK_FLAGS "${LINK_FLAGS_PROPERTIES}"
)

configure_clang_and_clang_tidy(${CMAKE_PROJECT_NAME})

if(WIN32)
target_link_libraries(${CMAKE_PROJECT_NAME}
${Qt5Core_QTMAIN_LIBRARIES}
Expand All @@ -1020,14 +1014,12 @@ endforeach()
# command), so now we use '_' instead...

if(WIN32)
qt5_wrap_cpp(WINDOWS_CLI_SOURCES_MOC ${WINDOWS_CLI_HEADERS_MOC})
qt5_add_resources(WINDOWS_CLI_SOURCES_RCS ${WINDOWS_CLI_RESOURCES})

set(WINDOWS_CLI_PROJECT_NAME ${CMAKE_PROJECT_NAME}_com)

add_executable(${WINDOWS_CLI_PROJECT_NAME}
${WINDOWS_CLI_SOURCES}
${WINDOWS_CLI_SOURCES_MOC}
${WINDOWS_CLI_SOURCES_RCS}
)

Expand All @@ -1038,6 +1030,8 @@ if(WIN32)
LINK_FLAGS "${LINK_FLAGS_PROPERTIES}"
)

configure_clang_and_clang_tidy(${WINDOWS_CLI_PROJECT_NAME})

target_link_libraries(${WINDOWS_CLI_PROJECT_NAME}
Qt5::Core
Qt5::Network
Expand Down

0 comments on commit e508ed2

Please sign in to comment.