mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-23 22:37:55 +02:00
CMake: cleanup, project generation and other improvements
- Use EXCLUDE_FROM_ALL for FuzzyLite and GoogleTest to avoid inclusion of unneded headers and libraries into installers. - Set minimum CMake version only in main CMakeLists.txt - Set project name only in main CMakeLists.txt - Visual Studio: add assign_source_group function to generate proper filesystem tree - Visual Studio: set PROJECT_LABEL so generated projects have same names binaries on Windows - Visual Studio: enabled USE_FOLDERS for projects grouping. This also possibly affect other IDEs. - Added add_subdirectory_with_folder function to make sure 3rd-party libraries are affected by USE_FOLDERS.
This commit is contained in:
@@ -16,3 +16,38 @@ macro(vcmi_set_output_dir name dir)
|
||||
set_target_properties(${name} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build/${dir})
|
||||
set_target_properties(${name} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build/${dir})
|
||||
endmacro()
|
||||
|
||||
#######################################
|
||||
# Better Visual Studio solution #
|
||||
#######################################
|
||||
|
||||
function(assign_source_group)
|
||||
foreach(_source IN ITEMS ${ARGN})
|
||||
if(IS_ABSOLUTE "${_source}")
|
||||
file(RELATIVE_PATH _source_rel "${CMAKE_CURRENT_SOURCE_DIR}" "${_source}")
|
||||
else()
|
||||
set(_source_rel "${_source}")
|
||||
endif()
|
||||
get_filename_component(_source_path "${_source_rel}" PATH)
|
||||
string(REPLACE "/" "\\" _source_path_msvc "${_source_path}")
|
||||
source_group("${_source_path_msvc}" FILES "${_source}")
|
||||
endforeach()
|
||||
endfunction(assign_source_group)
|
||||
|
||||
#######################################
|
||||
# Setting folders for 3rd-party #
|
||||
#######################################
|
||||
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS TRUE)
|
||||
define_property(
|
||||
TARGET
|
||||
PROPERTY FOLDER
|
||||
INHERITED
|
||||
BRIEF_DOCS "Set the folder name."
|
||||
FULL_DOCS "Use to organize targets in an IDE."
|
||||
)
|
||||
|
||||
function(add_subdirectory_with_folder _folder_name _folder)
|
||||
add_subdirectory(${_folder} ${ARGN})
|
||||
set_property(DIRECTORY "${_folder}" PROPERTY FOLDER "${_folder_name}")
|
||||
endfunction()
|
||||
|
||||
Reference in New Issue
Block a user