function(force_include target_name file_path) if (MSVC) target_compile_options(${target_name} PRIVATE /FI${file_path} ) else() target_compile_options(${target_name} PRIVATE -include ${file_path} ) endif() endfunction() function(init_target target_name) # init_target(my_target folder_name) set(folder_name "${ARGV1}") set_property(TARGET ${target_name} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") if (NOT "${folder_name}" STREQUAL "") set_target_properties(${target_name} PROPERTIES FOLDER ${folder_name}) endif() endfunction() function(nice_target_sources target_name src_loc list) set(writing_now "") set(private_sources "") set(public_sources "") set(interface_sources "") set(not_win_sources "") set(not_mac_sources "") set(not_linux_sources "") foreach(file ${list}) if (${file} STREQUAL "PRIVATE" OR ${file} STREQUAL "PUBLIC" OR ${file} STREQUAL "INTERFACE") set(writing_now ${file}) else() set(full_name ${src_loc}/${file}) if (${file} MATCHES "/win/" OR ${file} MATCHES "_win\\.") list(APPEND not_mac_sources ${full_name}) list(APPEND not_linux_sources ${full_name}) elseif (${file} MATCHES "/mac/" OR ${file} MATCHES "_mac\\.") list(APPEND not_win_sources ${full_name}) list(APPEND not_linux_sources ${full_name}) elseif (${file} MATCHES "/linux/" OR ${file} MATCHES "_linux\\.") list(APPEND not_win_sources ${full_name}) list(APPEND not_mac_sources ${full_name}) elseif (${file} MATCHES "/posix/" OR ${file} MATCHES "_posix\\.") list(APPEND not_win_sources ${full_name}) endif() if ("${writing_now}" STREQUAL "PRIVATE") list(APPEND private_sources ${full_name}) elseif ("${writing_now}" STREQUAL "PUBLIC") list(APPEND public_sources ${full_name}) elseif ("${writing_now}" STREQUAL "INTERFACE") list(APPEND interface_sources ${full_name}) else() message(FATAL_ERROR "Unknown sources scope for target ${target_name}") endif() source_group(TREE ${src_loc} FILES ${full_name}) endif() endforeach() if (NOT "${public_sources}" STREQUAL "") target_sources(${target_name} PUBLIC ${public_sources}) endif() if (NOT "${private_sources}" STREQUAL "") target_sources(${target_name} PRIVATE ${private_sources}) endif() if (NOT "${interface_sources}" STREQUAL "") target_sources(${target_name} INTERFACE ${interface_sources}) endif() if (WIN32) set_source_files_properties(${not_win_sources} PROPERTIES HEADER_FILE_ONLY TRUE) elseif (APPLE) set_source_files_properties(${not_mac_sources} PROPERTIES HEADER_FILE_ONLY TRUE) elseif (LINUX) set_source_files_properties(${not_linux_sources} PROPERTIES HEADER_FILE_ONLY TRUE) endif() endfunction()