diff --git a/CMake/CMakeSetCompilerFlags.cmake b/CMake/CMakeSetCompilerFlags.cmake index 76a5b3f1bb2941e8c250dbf7abe19939bba34126..10a277299b1124026dc110c9dc06824603863346 100644 --- a/CMake/CMakeSetCompilerFlags.cmake +++ b/CMake/CMakeSetCompilerFlags.cmake @@ -109,6 +109,8 @@ MACRO(ADD_COMPILER_FLAGS_TO_PROJECT compiler_type project_name project_language ################################################################ # LINKER PROPS ################################################################ + status("additional linker probs: ${CAB_COMPILER_ADDITIONAL_LINK_PROPS}") + IF(CAB_COMPILER_ADDITIONAL_LINK_PROPS) ADD_TARGET_PROPERTIES(${project_name} LINK_FLAGS ${CAB_COMPILER_ADDITIONAL_LINK_PROPS}) ENDIF() diff --git a/CMake/FileUtilities.cmake b/CMake/FileUtilities.cmake index 676d1ab567482492cc94c033b19486d2869c5e4c..604e6fe42d1acff91dc80f7d8d40c73704b2deb8 100644 --- a/CMake/FileUtilities.cmake +++ b/CMake/FileUtilities.cmake @@ -124,4 +124,53 @@ macro(generateExportHeader libName) #STATIC_DEFINE ${libName}_BUILT_AS_STATIC ) #endif() -endmacro(generateExportHeader) \ No newline at end of file +endmacro(generateExportHeader) + + + + +function(collectFiles source_files ARG_FILES ARG_FOLDER ARG_EXCLUDE) + set(local_source_files) + + #cmake_print_variables(ARG_FOLDER) + #cmake_print_variables(ARG_FILES) + #cmake_print_variables(ARG_EXCLUDE) + + if (ARG_FILES) + set(local_source_files ${local_source_files} ${ARG_FILES}) + endif() + + if (ARG_FOLDER) + foreach(folder ${ARG_FOLDER}) + foreach(file ${VIRTUAL_FLUIDS_GLOB_FILES}) + set (filePath ${folder}/${file}) + #message("${filePath}") + file (GLOB part_files ${filePath} ) + set(local_source_files ${local_source_files} ${part_files}) + #message("${local_source_files}") + endforeach() + endforeach() + endif() + + + if (NOT ARG_FILES AND NOT ARG_FOLDER) + file ( GLOB_RECURSE all_files ${VIRTUAL_FLUIDS_GLOB_FILES} ) + set(local_source_files ${local_source_files} ${all_files}) + endif() + + + if (ARG_EXCLUDE) + foreach(file_path ${local_source_files}) + foreach(file_exclude ${ARG_EXCLUDE}) + get_filename_component(file_name ${file_path} NAME) + if (NOT ${file_name} STREQUAL ${file_exclude}) + set(new_files ${new_files} ${file_path}) + endif() + + endforeach() + endforeach() + set(local_source_files ${new_files}) + endif() + + set("${source_files}" "${local_source_files}" PARENT_SCOPE) +endfunction() \ No newline at end of file diff --git a/CMake/VirtualFluidsMacros.cmake b/CMake/VirtualFluidsMacros.cmake index 5734fc4659eae4db68cd653d963513fdfe093bbc..ab37d42636ee59b56fded7c8ecde0f0912c33f30 100644 --- a/CMake/VirtualFluidsMacros.cmake +++ b/CMake/VirtualFluidsMacros.cmake @@ -58,78 +58,20 @@ endfunction() ## ################################################################################# function(vf_add_library) - message("Start new Cmake") set( options ) set( oneValueArgs ) set( multiValueArgs BUILDTYPE DEPENDS FILES FOLDER EXCLUDE) cmake_parse_arguments( ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) - #message("Files: ${ARG_FOLDER}") - vf_get_library_name (library_name) - message("LIB NAME: ${library_name}") - - - if (ARG_FILES) - #message ("${ARG_FILES}") - set(sourceFiles ${sourceFiles} ${ARG_FILES}) - endif() - - if (ARG_FOLDER) - foreach(folder ${ARG_FOLDER}) - foreach(file ${VIRTUAL_FLUIDS_GLOB_FILES}) - set (filePath ${folder}/${file}) - #message("${filePath}") - file (GLOB part_files ${filePath} ) - set(sourceFiles ${sourceFiles} ${part_files}) - endforeach() - endforeach() - endif() + status("Configuring the target: ${library_name} (type=${ARG_BUILDTYPE})...") - if (NOT ARG_FILES AND NOT ARG_FOLDER) - file ( GLOB_RECURSE all_files ${VIRTUAL_FLUIDS_GLOB_FILES} ) - set(sourceFiles ${sourceFiles} ${all_files}) - endif() - - foreach(X IN LISTS sourceFiles) - #message(STATUS "${X}") - endforeach() - - if (ARG_EXCLUDE) - foreach(file_path ${sourceFiles}) - foreach(file_exclude ${ARG_EXCLUDE}) - get_filename_component(file_name ${file_path} NAME) - if (NOT ${file_name} STREQUAL ${file_exclude}) - set(new_files ${new_files} ${file_path}) - endif() - - endforeach() - endforeach() - set(sourceFiles ${new_files}) - endif() + collectFiles(sourceFiles "${ARG_FILES}" "${ARG_FOLDER}" "${ARG_EXCLUDE}") includeProductionFiles (${library_name} "${sourceFiles}") - foreach(X IN LISTS MY_SRCS) - #message(STATUS "${X}") - endforeach() - - - # SET SOURCE GROUP - # IF SOURCE GROUP ENABLED - foreach(source ${sourceFiles}) - # get_filename_component(source_dir ${source} DIRECTORY) - - if (source_dir) - #setSourceGroupForFilesIn(${source_dir} ${library_name}) - endif() - endforeach() - - - - MESSAGE(STATUS "configuring ${library_name} (type=${ARG_BUILDTYPE})...") ################################################################# @@ -153,10 +95,13 @@ function(vf_add_library) ################################################################# IF(${ARG_BUILDTYPE} MATCHES binary) ADD_EXECUTABLE(${library_name} ${MY_SRCS} ) + groupTarget(${library_name} ${appFolder}) ELSEIF(${ARG_BUILDTYPE} MATCHES shared) ADD_LIBRARY(${library_name} SHARED ${MY_SRCS} ) + groupTarget(${library_name} ${libraryFolder}) ELSEIF(${ARG_BUILDTYPE} MATCHES static) ADD_LIBRARY(${library_name} STATIC ${MY_SRCS} ) + groupTarget(${library_name} ${libraryFolder}) ELSE() MESSAGE(FATAL_ERROR "build_type=${ARG_BUILDTYPE} doesn't match BINARY, SHARED or STATIC") ENDIF() @@ -164,21 +109,18 @@ function(vf_add_library) ################################################################# ### ADDITIONAL LINK LIBRARIES ### ################################################################# - message("Link Depending Libraries: ${ARG_DEPENDS}") + status("Link Depending Libraries: ${ARG_DEPENDS}") if (ARG_DEPENDS) target_link_libraries(${library_name} PRIVATE ${ARG_DEPENDS}) endif() - IF(CAB_ADDITIONAL_LINK_LIBRARIES) - TARGET_LINK_LIBRARIES(${library_name} PRIVATE ${CAB_ADDITIONAL_LINK_LIBRARIES}) - ENDIF() - - ################################################################# ### COMPILER Flags ### ################################################################# ADD_COMPILER_FLAGS_TO_PROJECT(${CAB_COMPILER} ${library_name} "CXX" ${ARG_BUILDTYPE}) - MESSAGE(STATUS "compiler flags for compiler ${CAB_COMPILER} on machine ${CAB_MACHINE} for project ${project_name} (${ARG_BUILDTYPE}) have been configured") + status("compiler flags for compiler ${CAB_COMPILER} on machine ${CAB_MACHINE} for project ${project_name} (${ARG_BUILDTYPE}) have been configured") + status("compiler flags: ${CAB_COMPILER_ADDTIONAL_CXX_COMPILER_FLAGS}") + status("additional compiler flags: ${CAB_ADDTIONAL_COMPILER_FLAGS}") #MESSAGE (COMPILE FLAGS: ${CAB_ADDTIONAL_COMPILER_FLAGS}) IF(CAB_ADDTIONAL_COMPILER_FLAGS) @@ -196,6 +138,8 @@ function(vf_add_library) ################################################################# ### ADDITIONAL LINK PROPERTIES ### ################################################################# + status("additional linker flags: ${CAB_ADDITIONAL_LINK_FLAGS}") + IF(CAB_ADDITIONAL_LINK_FLAGS) ADD_TARGET_PROPERTIES(${library_name} LINK_FLAGS ${CAB_ADDITIONAL_LINK_FLAGS}) ENDIF() @@ -206,9 +150,6 @@ function(vf_add_library) ADD_TARGET_PROPERTIES(${library_name} LINK_FLAGS_RELEASE ${CAB_ADDITIONAL_LINK_FLAGS_RELEASE}) ENDIF() - #SET(project_name ${library_name} CACHE STRING "name of binary") - - MESSAGE(STATUS "configuring ${library_name} (type=${ARG_BUILDTYPE})... done") if (NOT ${ARG_BUILDTYPE} MATCHES binary) generateExportHeader (${library_name}) @@ -219,6 +160,8 @@ function(vf_add_library) target_include_directories(${library_name} PRIVATE ${CMAKE_SOURCE_DIR}/src) + #status("... configuring target: ${library_name} (type=${ARG_BUILDTYPE}) done") + endfunction() @@ -240,7 +183,7 @@ function(vf_add_tests) vf_get_library_test_name(library_test_name) vf_get_library_name (folder_name) - status("Add test executable: ${library_test_name}") + status("Configuring test executable: ${library_test_name}") # set test files to MY_SRCS file ( GLOB_RECURSE all_files ${VIRTUAL_FLUIDS_GLOB_FILES} ) @@ -248,6 +191,7 @@ function(vf_add_tests) # add the target add_executable(${library_test_name} ${MY_SRCS}) + groupTarget (${library_test_name} ${testFolder}) # link tested library target_link_libraries(${library_test_name} PRIVATE ${folder_name}) @@ -261,3 +205,10 @@ function(vf_add_tests) include(${CMAKE_PATH}/3rd/gmock.cmake) endfunction() + +################################################################################# +## group target for VisualStudio +################################################################################# +function(groupTarget targetName folderName) + set_property( TARGET ${targetName} PROPERTY FOLDER ${folderName} ) +endfunction(groupTarget) \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 2bc92ad80063993d9df23ab2eef94a7ed8a1c4a9..56eb1cb560e80aa1e9a7322ab1f708bcdd3f52fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,12 @@ endif() project(VirtualFluids CXX) +set_property(GLOBAL PROPERTY USE_FOLDERS ON) +set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER ".cmake") +set(libraryFolder "libs") +set(testFolder "tests") +set(appFolder "apps") + ################################################################################# # OPTIONS ################################################################################# diff --git a/gpu.cmake b/gpu.cmake index 2be43a5aef95dc3c254d4f02119282910cd023fa..1be1fff37b1244c1a129581d2423d7734b005850 100644 --- a/gpu.cmake +++ b/gpu.cmake @@ -56,9 +56,6 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) set(CMAKE_INCLUDE_CURRENT_DIR ON) include_directories(${CMAKE_BINARY_DIR}/gpu) -set_property(GLOBAL PROPERTY USE_FOLDERS ON) -set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER ".cmake") - set(libraryFolder "libs") set(gksLibraryFolder "libs/GKS") diff --git a/src/basics/Core/buildInfo.cmake b/src/basics/Core/buildInfo.cmake index 44935fedbd198a5d783d1cf32a15985e50d13f8c..91972c43d54037beb194b7c8a30c3aca43784edb 100644 --- a/src/basics/Core/buildInfo.cmake +++ b/src/basics/Core/buildInfo.cmake @@ -8,9 +8,9 @@ get_git_head_revision(git_branch git_commit_hash) set(COMPILER_FLAGS "${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}} ${CMAKE_CXX_FLAGS}") configure_file(${buildInfoInput} ${buildInfoPath}/${buildInfoFile}) -message ("buildInfoPath: ${buildInfoPath}") +#message ("buildInfoPath: ${buildInfoPath}") include_directories(${buildInfoPath}) #set(MY_SRCS ${MY_SRCS} ${buildInfoPath}/${buildInfoFile} ${CMAKE_CURRENT_LIST_DIR}/${buildInfoFileHeader}) -set(sourceFiles ${sourceFiles} ${buildInfoPath}/${buildInfoFile}) +set(MY_SRCS ${MY_SRCS} ${buildInfoPath}/${buildInfoFile}) source_group("" FILES ${buildInfoPath}/${buildInfoFile}) #source_group("" FILES ${CMAKE_CURRENT_LIST_DIR}/${buildInfoFileHeader}) \ No newline at end of file diff --git a/src/cpu/VirtualFluidsCore/CMakeLists.txt b/src/cpu/VirtualFluidsCore/CMakeLists.txt index 472b2e5c28f6756bdef0a613cbd7785bc0369dde..48e357c496102890e952fb958a25d22ef250961b 100644 --- a/src/cpu/VirtualFluidsCore/CMakeLists.txt +++ b/src/cpu/VirtualFluidsCore/CMakeLists.txt @@ -88,14 +88,14 @@ IF(${USE_DEM_COUPLING}) INCLUDE(${SOURCE_ROOT}/DemCoupling/DemCoupling.cmake) ENDIF() -message("CAB_ADDITIONAL_LINK_LIBRARIES: " ${CAB_ADDITIONAL_LINK_LIBRARIES}) +#message("CAB_ADDITIONAL_LINK_LIBRARIES: " ${CAB_ADDITIONAL_LINK_LIBRARIES}) ################################################################# ### CREATE PROJECT ### ################################################################# #CREATE_CAB_PROJECT(VirtualFluids STATIC) #include (${CMAKE_SOURCE_DIR}/CMake/VirtualFluidsMacros.cmake) -vf_add_library(BUILDTYPE static DEPENDS basics MuParser ${MPI_LIBRARY}) +vf_add_library(BUILDTYPE static DEPENDS basics MuParser ${CAB_ADDITIONAL_LINK_LIBRARIES}) vf_get_library_name(library_name) target_include_directories(${library_name} PRIVATE ${CMAKE_SOURCE_DIR}/src/basics)