diff --git a/CMake/VirtualFluidsMacros.cmake b/CMake/VirtualFluidsMacros.cmake index 033a4aad9a06d64634df0fcdfd4de4c403e5d9ea..14309caeb84668682f7ae013fead67b248f0e53c 100644 --- a/CMake/VirtualFluidsMacros.cmake +++ b/CMake/VirtualFluidsMacros.cmake @@ -102,17 +102,6 @@ endfunction() ################################################################################# function(vf_add_library) - # enable clang tidy for this target - if(BUILD_VF_CLANG_TIDY) - find_program(CLANG_TIDY_COMMAND NAMES clang-tidy) - - if(NOT CLANG_TIDY_COMMAND) - message(FATAL_ERROR "Clang-tidy command not found.") - endif() - - set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND}") - endif() - set( options ) set( oneValueArgs ) set( multiValueArgs NAME BUILDTYPE PUBLIC_LINK PRIVATE_LINK FILES FOLDER EXCLUDE) @@ -131,7 +120,7 @@ function(vf_add_library) includeProductionFiles (${library_name} "${sourceFiles}") ################################################################# - ### EXCECUTABLE ### + ### ADD TARGET ### ################################################################# IF(${ARG_BUILDTYPE} MATCHES binary) ADD_EXECUTABLE(${library_name} ${MY_SRCS} ) @@ -154,11 +143,41 @@ function(vf_add_library) ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") + # clang-tidy + if(BUILD_VF_CLANG_TIDY) + find_program(CLANG_TIDY_PROGRAM NAMES clang-tidy) + + if(NOT CLANG_TIDY_PROGRAM) + message(FATAL_ERROR "Could not find the program clang-tidy.") + endif() + + set_target_properties(${library_name} + PROPERTIES + CXX_CLANG_TIDY ${CLANG_TIDY_PROGRAM}) + + status_lib("clang-tidy enabled") + endif() + + # include-what-you-use + if(BUILD_VF_INCLUDE_WHAT_YOU_USE) + find_program(IWYU_PROGRAM NAMES include-what-you-use iwyu) + + if(NOT IWYU_PROGRAM) + message(FATAL_ERROR "Could not find the program include-what-you-use") + endif() + + set_target_properties(${library_name} + PROPERTIES + CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PROGRAM}) + + status_lib("include-what-you-use enabled") + endif() + ################################################################# ### ADDITIONAL LINK LIBRARIES ### ################################################################# - status_lib("Link Depending Libraries: ${ARG_PUBLIC_LINK}") - status_lib("Link Depending Libraries: ${ARG_PRIVATE_LINK}") + status_lib("Link Depending public libraries: ${ARG_PUBLIC_LINK}") + status_lib("Link Depending private libraries: ${ARG_PRIVATE_LINK}") if (ARG_PUBLIC_LINK) target_link_libraries(${library_name} PUBLIC ${ARG_PUBLIC_LINK}) endif() diff --git a/CMakeLists.txt b/CMakeLists.txt index c644b97869050b8c5a00ae43583997ca49ef325c..f6176bae09f384c35a01a025e3f0f5fc6ffc0858 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,6 +39,7 @@ option(BUILD_VF_GPU "Build VirtualFluids gpu variant" OFF) option(BUILD_VF_UNIT_TESTS "Build VirtualFluids unit tests" OFF) option(BUILD_VF_CLANG_TIDY "Add the clang tidy checks to the targets" OFF) +option(BUILD_VF_INCLUDE_WHAT_YOU_USE "Add IWYU to the targets" OFF) option(BUILD_SHARED_LIBS "" ON)