[CMAKE/VS]

* Introduce the support for organizing the solution into a hierarchy of folders that matches our codebase layout.
* You can enable this feature by adding -DUSE_FOLDER_STRUCTURE=1 to your configure phase (the VSSolution one).
* Based on a patch by Yuntian Zhang with my improvements.
CORE-7412

svn path=/trunk/; revision=59860
This commit is contained in:
Amine Khaldi 2013-08-28 21:37:54 +00:00
parent bf493b93af
commit e3f48f8607
2 changed files with 29 additions and 0 deletions

View file

@ -345,6 +345,32 @@ if(NOT MSVC_IDE)
_add_executable(${name} ${ARGN})
add_clean_target(${name})
endfunction()
elseif(USE_FOLDER_STRUCTURE)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
string(LENGTH ${CMAKE_SOURCE_DIR} CMAKE_SOURCE_DIR_LENGTH)
function(add_custom_target name)
_add_custom_target(${name} ${ARGN})
string(SUBSTRING ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR_LENGTH} -1 CMAKE_CURRENT_SOURCE_DIR_RELATIVE)
set_property(TARGET "${name}" PROPERTY FOLDER "${CMAKE_CURRENT_SOURCE_DIR_RELATIVE}")
endfunction()
function(add_library name)
_add_library(${name} ${ARGN})
get_target_property(_target_excluded ${name} EXCLUDE_FROM_ALL)
if(_target_excluded AND ${name} MATCHES "^lib.*")
set_property(TARGET "${name}" PROPERTY FOLDER "Importlibs")
else()
string(SUBSTRING ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR_LENGTH} -1 CMAKE_CURRENT_SOURCE_DIR_RELATIVE)
set_property(TARGET "${name}" PROPERTY FOLDER "${CMAKE_CURRENT_SOURCE_DIR_RELATIVE}")
endif()
endfunction()
function(add_executable name)
_add_executable(${name} ${ARGN})
string(SUBSTRING ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR_LENGTH} -1 CMAKE_CURRENT_SOURCE_DIR_RELATIVE)
set_property(TARGET "${name}" PROPERTY FOLDER "${CMAKE_CURRENT_SOURCE_DIR_RELATIVE}")
endfunction()
endif()
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")

View file

@ -45,6 +45,9 @@ endif()
if(MSVC_IDE)
add_compile_flags("/MP")
if(NOT DEFINED USE_FOLDER_STRUCTURE)
set(USE_FOLDER_STRUCTURE FALSE)
endif()
endif()
if(${_MACHINE_ARCH_FLAG} MATCHES X86)