CMake: Remove the workaround for source groups below CMake 2.8.12

* Set the default option to hierarchical
* Add a new "hierarchical-folders" option which enables folders inside IDE's.
This commit is contained in:
Aokromes
2016-08-09 23:49:31 +02:00
parent fee20bf1d9
commit b96f20c0d4
4 changed files with 14 additions and 24 deletions

View File

@@ -10,7 +10,7 @@
macro(GroupSources dir)
# Skip this if WITH_SOURCE_TREE is not set (empty string).
if (NOT ${_WITH_SOURCE_TREE} STREQUAL "")
if (NOT ${WITH_SOURCE_TREE} STREQUAL "")
# Include all header and c files
file(GLOB_RECURSE elements RELATIVE ${dir} *.h *.hpp *.c *.cpp *.cc)
@@ -21,7 +21,7 @@ macro(GroupSources dir)
if (NOT ${element_dir} STREQUAL "")
# If the file is in a subdirectory use it as source group.
if (${_WITH_SOURCE_TREE} STREQUAL "flat")
if (${WITH_SOURCE_TREE} STREQUAL "flat")
# Build flat structure by using only the first subdirectory.
string(FIND ${element_dir} "/" delemiter_pos)
if (NOT ${delemiter_pos} EQUAL -1)
@@ -44,3 +44,8 @@ macro(GroupSources dir)
endforeach()
endif()
endmacro()
if (WITH_SOURCE_TREE STREQUAL "hierarchical-folders")
# Use folders
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
endif()

View File

@@ -16,6 +16,6 @@ option(USE_COREPCH "Use precompiled headers when compiling servers"
option(WITH_DYNAMIC_LINKING "Enable dynamic library linking." 0)
option(WITH_WARNINGS "Show all warnings during compile" 0)
option(WITH_COREDEBUG "Include additional debug-code in core" 0)
set(WITH_SOURCE_TREE "no" CACHE STRING "Build the source tree for IDE's.")
set_property(CACHE WITH_SOURCE_TREE PROPERTY STRINGS no flat hierarchical)
set(WITH_SOURCE_TREE "hierarchical" CACHE STRING "Build the source tree for IDE's.")
set_property(CACHE WITH_SOURCE_TREE PROPERTY STRINGS no flat hierarchical hierarchical-folders)
option(WITHOUT_GIT "Disable the GIT testing routines" 0)

View File

@@ -69,27 +69,10 @@ else()
message("* Use coreside debug : No (default)")
endif()
if( WITH_SOURCE_TREE STREQUAL "flat" OR WITH_SOURCE_TREE STREQUAL "hierarchical" )
# TODO: Remove this after Debian 8 is released and set general required version to 2.8.12
# Debian 7 is shipped with CMake 2.8.9 . But DIRECTORY flag of get_filename_component requires 2.8.12 .
if (NOT CMAKE_VERSION VERSION_LESS 2.8.12)
message("* Show source tree : Yes - ${WITH_SOURCE_TREE}")
set(_WITH_SOURCE_TREE ${WITH_SOURCE_TREE} CACHE INTERNAL "WITH_SOURCE_TREE support enabled.")
else()
message("* Show source tree : No (default)")
message("")
message(" *** WITH_SOURCE_TREE - WARNING!")
message(" *** This functionality is ONLY supported on CMake 2.8.12 or higher.")
message(" *** You are running ${CMAKE_VERSION}, which does not have the functions needed")
message(" *** to create a sourcetree - this option is thus forced to disabled!")
message("")
set(_WITH_SOURCE_TREE "" CACHE INTERNAL "WITH_SOURCE_TREE support disabled.")
endif()
if( NOT WITH_SOURCE_TREE STREQUAL "no" )
message("* Show source tree : Yes - \"${WITH_SOURCE_TREE}\"")
else()
message("* Show source tree : No (default)")
set(_WITH_SOURCE_TREE "" CACHE INTERNAL "WITH_SOURCE_TREE support disabled.")
message("* Show source tree : No")
endif()
if ( WITHOUT_GIT )

View File

@@ -76,6 +76,8 @@ include_directories(
${ZMQ_INCLUDE_DIR}
)
GroupSources(${CMAKE_CURRENT_SOURCE_DIR})
add_executable(bnetserver
${bnetserver_SRCS}
${bnetserver_PCH_SRC}