summaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
authorKargatum <dowlandtop@yandex.com>2022-05-31 17:05:39 +0700
committerGitHub <noreply@github.com>2022-05-31 17:05:39 +0700
commit4fbec972a8fe55d73744205322298791ded0c204 (patch)
tree9b183311815b3a25c46ea11e99c73c548460a0fb /src/tools
parent40a5eef152addba3949016938519fa61d9776f82 (diff)
refactor(Cmake): add support build selected applications and tools (#11836)
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/CMakeLists.txt156
-rw-r--r--src/tools/map_extractor/CMakeLists.txt55
-rw-r--r--src/tools/mmaps_generator/CMakeLists.txt50
-rw-r--r--src/tools/vmap4_assembler/CMakeLists.txt38
-rw-r--r--src/tools/vmap4_extractor/CMakeLists.txt46
5 files changed, 151 insertions, 194 deletions
diff --git a/src/tools/CMakeLists.txt b/src/tools/CMakeLists.txt
index 046265c771..9ce44a36e3 100644
--- a/src/tools/CMakeLists.txt
+++ b/src/tools/CMakeLists.txt
@@ -8,9 +8,155 @@
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-#
-add_subdirectory(map_extractor)
-add_subdirectory(vmap4_assembler)
-add_subdirectory(vmap4_extractor)
-add_subdirectory(mmaps_generator)
+# Make the tools list available in the current scope
+GetToolsList(TOOLS_BUILD_LIST)
+
+if (TOOLS_BUILD STREQUAL "none")
+ set(TOOLS_DEFAULT_BUILD "disabled")
+else()
+ set(TOOLS_DEFAULT_BUILD "enabled")
+endif()
+
+# Sets BUILD_TOOLS_USE_WHITELIST
+# Sets BUILD_TOOLS_WHITELIST
+if (TOOLS_BUILD MATCHES "-only")
+ set(BUILD_TOOLS_USE_WHITELIST ON)
+
+ if (TOOLS_BUILD STREQUAL "maps-only")
+ list(APPEND BUILD_TOOLS_WHITELIST map_extractor mmaps_generator vmap4_assembler vmap4_extractor)
+ endif()
+
+ # if (TOOLS_BUILD STREQUAL "db-only")
+ # list(APPEND BUILD_TOOLS_WHITELIST dbimport)
+ # endif()
+endif()
+
+# Set the TOOL_${TOOL_BUILD_NAME} variables from the
+# variables set above
+foreach(TOOL_BUILD_NAME ${TOOLS_BUILD_LIST})
+ ToolNameToVariable(${TOOL_BUILD_NAME} TOOL_BUILD_VARIABLE)
+
+ if(${TOOL_BUILD_VARIABLE} STREQUAL "default")
+ if(BUILD_TOOLS_USE_WHITELIST)
+ list(FIND BUILD_TOOLS_WHITELIST "${TOOL_BUILD_NAME}" INDEX)
+ if(${INDEX} GREATER -1)
+ set(${TOOL_BUILD_VARIABLE} ${TOOLS_DEFAULT_BUILD})
+ else()
+ set(${TOOL_BUILD_VARIABLE} "disabled")
+ endif()
+ else()
+ set(${TOOL_BUILD_VARIABLE} ${TOOLS_DEFAULT_BUILD})
+ endif()
+ endif()
+
+ # Build the Graph values
+ if(${TOOL_BUILD_VARIABLE} MATCHES "enabled")
+ list(APPEND TOOL_BUILD_GRAPH_KEYS tools)
+ set(TOOL_BUILD_VALUE_DISPLAY_tools tools)
+ list(APPEND TOOL_BUILD_VALUE_CONTAINS_tools ${TOOL_BUILD_NAME})
+ else()
+ list(APPEND TOOL_BUILD_GRAPH_KEYS disabled)
+ set(TOOL_BUILD_VALUE_DISPLAY_disabled disabled)
+ list(APPEND TOOL_BUILD_VALUE_CONTAINS_disabled ${TOOL_BUILD_NAME})
+ endif()
+endforeach()
+
+list(SORT TOOL_BUILD_GRAPH_KEYS)
+list(REMOVE_DUPLICATES TOOL_BUILD_GRAPH_KEYS)
+
+# Display the graphs
+# message("")
+message("* Tools build list (${TOOLS_BUILD}):")
+message(" |")
+
+foreach(TOOL_BUILD_GRAPH_KEY ${TOOL_BUILD_GRAPH_KEYS})
+ if(NOT TOOL_BUILD_GRAPH_KEY STREQUAL "disabled")
+ message(" +- ${TOOL_BUILD_VALUE_DISPLAY_${TOOL_BUILD_GRAPH_KEY}}")
+ else()
+ message(" | ${TOOL_BUILD_VALUE_DISPLAY_${TOOL_BUILD_GRAPH_KEY}}")
+ endif()
+ foreach(TOOL_BUILD_GRAPH_ENTRY ${TOOL_BUILD_VALUE_CONTAINS_${TOOL_BUILD_GRAPH_KEY}})
+ message(" | +- ${TOOL_BUILD_GRAPH_ENTRY}")
+ endforeach()
+ message(" |")
+endforeach()
+
+message("")
+
+GroupSources(${CMAKE_CURRENT_SOURCE_DIR})
+
+# Generates the actual tools projects
+foreach(TOOL_NAME ${TOOLS_BUILD_LIST})
+ GetPathToTool(${TOOL_NAME} SOURCE_TOOL_PATH)
+ ToolNameToVariable(${TOOL_NAME} TOOL_BUILD_VARIABLE)
+
+ if (${TOOL_BUILD_VARIABLE} STREQUAL "disabled")
+ continue()
+ endif()
+
+ unset(TOOL_PRIVATE_SOURCES)
+ CollectSourceFiles(
+ ${SOURCE_TOOL_PATH}
+ TOOL_PRIVATE_SOURCES)
+
+ if (WIN32)
+ list(APPEND TOOL_PRIVATE_SOURCES ${winDebugging})
+ endif()
+
+ GetProjectNameOfToolName(${TOOL_NAME} TOOL_PROJECT_NAME)
+
+ # Create the application project
+ add_executable(${TOOL_PROJECT_NAME}
+ ${TOOL_PRIVATE_SOURCES})
+
+ add_dependencies(${TOOL_PROJECT_NAME} revision.h)
+
+ # Need fix errors
+ # target_link_libraries(${TOOL_PROJECT_NAME}
+ # PRIVATE
+ # acore-core-interface)
+
+ # if (${TOOL_PROJECT_NAME} MATCHES "dbimport")
+ # target_link_libraries(${TOOL_PROJECT_NAME}
+ # PUBLIC
+ # database)
+
+ # # Install config
+ # CopyToolConfig(${TOOL_PROJECT_NAME} ${TOOL_NAME})
+ # else()
+ target_link_libraries(${TOOL_PROJECT_NAME}
+ PUBLIC
+ common
+ mpq
+ zlib
+ Recast
+ g3dlib)
+ # endif()
+
+ unset(TOOL_PUBLIC_INCLUDES)
+ CollectIncludeDirectories(
+ ${SOURCE_TOOL_PATH}
+ TOOL_PUBLIC_INCLUDES)
+
+ target_include_directories(${TOOL_PROJECT_NAME}
+ PUBLIC
+ ${CMAKE_CURRENT_SOURCE_DIR})
+
+ target_include_directories(${TOOL_PROJECT_NAME}
+ PUBLIC
+ ${TOOL_PUBLIC_INCLUDES}
+ PRIVATE
+ ${CMAKE_CURRENT_BINARY_DIR}/${TOOL_NAME})
+
+ set_target_properties(${TOOL_PROJECT_NAME}
+ PROPERTIES
+ FOLDER
+ "tools")
+
+ if (UNIX)
+ install(TARGETS ${TOOL_PROJECT_NAME} DESTINATION bin)
+ elseif (WIN32)
+ install(TARGETS ${TOOL_PROJECT_NAME} DESTINATION "${CMAKE_INSTALL_PREFIX}")
+ endif()
+endforeach()
diff --git a/src/tools/map_extractor/CMakeLists.txt b/src/tools/map_extractor/CMakeLists.txt
deleted file mode 100644
index 5b092c7c91..0000000000
--- a/src/tools/map_extractor/CMakeLists.txt
+++ /dev/null
@@ -1,55 +0,0 @@
-#
-# This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
-#
-# This file is free software; as a special exception the author gives
-# unlimited permission to copy and/or distribute it, with or without
-# modifications, as long as this notice is preserved.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
-# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-#
-
-CollectSourceFiles(
- ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE_SOURCES)
-
-add_executable(mapextractor
- ${PRIVATE_SOURCES}
-)
-
-target_include_directories(mapextractor
- PUBLIC
- ${CMAKE_SOURCE_DIR}
- ${CMAKE_CURRENT_SOURCE_DIR}/loadlib)
-
-target_link_libraries(mapextractor
- PRIVATE
- acore-core-interface
- PUBLIC
- common
- mpq)
-
-CollectIncludeDirectories(
- ${CMAKE_CURRENT_SOURCE_DIR}
- PUBLIC_INCLUDES)
-
-# Group sources
-GroupSources(${CMAKE_CURRENT_SOURCE_DIR})
-
-target_include_directories(mapextractor
- PUBLIC
- ${PUBLIC_INCLUDES}
- PRIVATE
- ${CMAKE_CURRENT_BINARY_DIR})
-
-set_target_properties(mapextractor
- PROPERTIES
- FOLDER
- "tools")
-
-if( UNIX )
- install(TARGETS mapextractor DESTINATION bin)
-elseif( WIN32 )
- install(TARGETS mapextractor DESTINATION "${CMAKE_INSTALL_PREFIX}")
-endif()
diff --git a/src/tools/mmaps_generator/CMakeLists.txt b/src/tools/mmaps_generator/CMakeLists.txt
deleted file mode 100644
index c7d295acb3..0000000000
--- a/src/tools/mmaps_generator/CMakeLists.txt
+++ /dev/null
@@ -1,50 +0,0 @@
-#
-# This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
-#
-# This file is free software; as a special exception the author gives
-# unlimited permission to copy and/or distribute it, with or without
-# modifications, as long as this notice is preserved.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
-# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-#
-
-CollectSourceFiles(
- ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE_SOURCES)
-
-add_executable(mmaps_generator ${PRIVATE_SOURCES})
-
-target_link_libraries(mmaps_generator
- PRIVATE
- acore-core-interface
- PUBLIC
- common
- Recast
- mpq)
-
-# Group sources
-GroupSources(${CMAKE_CURRENT_SOURCE_DIR})
-
-CollectIncludeDirectories(
- ${CMAKE_CURRENT_SOURCE_DIR}
- PUBLIC_INCLUDES)
-
-target_include_directories(mmaps_generator
- PUBLIC
- ${PUBLIC_INCLUDES}
- PRIVATE
- ${CMAKE_CURRENT_BINARY_DIR}
- ${CMAKE_SOURCE_DIR}/src/server/game/Conditions)
-
-set_target_properties(mmaps_generator
- PROPERTIES
- FOLDER
- "tools")
-
-if( UNIX )
- install(TARGETS mmaps_generator DESTINATION bin)
-elseif( WIN32 )
- install(TARGETS mmaps_generator DESTINATION "${CMAKE_INSTALL_PREFIX}")
-endif()
diff --git a/src/tools/vmap4_assembler/CMakeLists.txt b/src/tools/vmap4_assembler/CMakeLists.txt
deleted file mode 100644
index 0b0108d7c0..0000000000
--- a/src/tools/vmap4_assembler/CMakeLists.txt
+++ /dev/null
@@ -1,38 +0,0 @@
-#
-# This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
-#
-# This file is free software; as a special exception the author gives
-# unlimited permission to copy and/or distribute it, with or without
-# modifications, as long as this notice is preserved.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
-# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-#
-
-add_executable(vmap4assembler VMapAssembler.cpp)
-
-if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
- set_target_properties(vmap4assembler PROPERTIES LINK_FLAGS "-framework Carbon")
-endif()
-
-target_link_libraries(vmap4assembler
- PRIVATE
- acore-core-interface
- PUBLIC
- common
- zlib)
-
-# Group sources
-GroupSources(${CMAKE_CURRENT_SOURCE_DIR})
-
-set_target_properties(vmap4assembler
- PROPERTIES
- FOLDER
- "tools")
-
-if( UNIX )
- install(TARGETS vmap4assembler DESTINATION bin)
-elseif( WIN32 )
- install(TARGETS vmap4assembler DESTINATION "${CMAKE_INSTALL_PREFIX}")
-endif()
diff --git a/src/tools/vmap4_extractor/CMakeLists.txt b/src/tools/vmap4_extractor/CMakeLists.txt
deleted file mode 100644
index cc0a69548d..0000000000
--- a/src/tools/vmap4_extractor/CMakeLists.txt
+++ /dev/null
@@ -1,46 +0,0 @@
-#
-# This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
-#
-# This file is free software; as a special exception the author gives
-# unlimited permission to copy and/or distribute it, with or without
-# modifications, as long as this notice is preserved.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
-# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-#
-
-CollectSourceFiles(
- ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE_SOURCES)
-
-add_executable(vmap4extractor ${PRIVATE_SOURCES})
-
-target_link_libraries(vmap4extractor
- PUBLIC
- g3dlib
- mpq)
-
-# Group sources
-GroupSources(${CMAKE_CURRENT_SOURCE_DIR})
-
-CollectIncludeDirectories(
- ${CMAKE_CURRENT_SOURCE_DIR}
- PUBLIC_INCLUDES)
-
-target_include_directories(vmap4extractor
- PUBLIC
- ${PUBLIC_INCLUDES}
- PRIVATE
- ${CMAKE_CURRENT_BINARY_DIR})
-
-set_target_properties(vmap4extractor
- PROPERTIES
- FOLDER
- "tools")
-
-if( UNIX )
- install(TARGETS vmap4extractor DESTINATION bin)
-elseif( WIN32 )
- install(TARGETS vmap4extractor DESTINATION "${CMAKE_INSTALL_PREFIX}")
-endif()