summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt87
1 files changed, 74 insertions, 13 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 105f234f1..4358f6bce 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -323,25 +323,84 @@ if (MSVC)
endif()
+
+
+
add_executable(${CMAKE_PROJECT_NAME} ${SOURCE})
# Output the executable into the $/Server folder, so that it has access to external resources:
SET_TARGET_PROPERTIES(${CMAKE_PROJECT_NAME} PROPERTIES
- RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/Server
- RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/Server
- RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/Server
- RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_SOURCE_DIR}/Server
- RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_SOURCE_DIR}/Server
- RUNTIME_OUTPUT_DIRECTORY_DEBUGPROFILE ${CMAKE_SOURCE_DIR}/Server
- RUNTIME_OUTPUT_DIRECTORY_RELEASEPROFILE ${CMAKE_SOURCE_DIR}/Server
+ RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Server
+ RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/Server
+ RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/Server
+ RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_BINARY_DIR}/Server
+ RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_BINARY_DIR}/Server
+ RUNTIME_OUTPUT_DIRECTORY_DEBUGPROFILE ${CMAKE_BINARY_DIR}/Server
+ RUNTIME_OUTPUT_DIRECTORY_RELEASEPROFILE ${CMAKE_BINARY_DIR}/Server
+)
+
+
+
+
+
+# Create a symbolic link from ${orig} to ${link}
+# If ${link} already exists, does nothing.
+function(make_symlink orig link)
+ # Get OS dependent path to use in `execute_process`
+ message("Creating symlink, orig = ${orig}; link = ${link}")
+ file(TO_NATIVE_PATH "${orig}" orig)
+ file(TO_NATIVE_PATH "${link}" link)
+
+ if (NOT EXISTS ${link})
+ if (CMAKE_HOST_UNIX)
+ set(command ln -s ${orig} ${link})
+ else()
+ if (IS_DIRECTORY ${orig})
+ set(command cmd.exe /c mklink /j ${link} ${orig})
+ else()
+ set(command cmd.exe /c mklink /h ${link} ${orig})
+ endif()
+ endif()
+
+ execute_process(COMMAND ${command}
+ RESULT_VARIABLE result
+ ERROR_VARIABLE output)
+
+ if (NOT ${result} EQUAL 0)
+ message(FATAL_ERROR "Could not create symbolic link for: ${link} --> ${orig}: ${output}")
+ endif()
+ endif()
+endfunction(make_symlink)
+
+
+
+
+
+# Populate the output folder with symlinks to the Server folder's internals:
+set(symlinks
+ Install
+ lang
+ Plugins
+ Prefabs
+ Protocol
+ webadmin
+ brewing.txt
+ crafting.txt
+ favicon.png
+ items.ini
+ monsters.ini
)
+message("Creating output folder and symlinks...")
+file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/Server")
+foreach (symlink ${symlinks})
+ make_symlink("${CMAKE_SOURCE_DIR}/Server/${symlink}" "${CMAKE_BINARY_DIR}/Server/${symlink}")
+endforeach(symlink)
+make_symlink("${CMAKE_SOURCE_DIR}/BACKERS" "${CMAKE_BINARY_DIR}/Server/BACKERS")
+make_symlink("${CMAKE_SOURCE_DIR}/CONTRIBUTORS" "${CMAKE_BINARY_DIR}/Server/CONTRIBUTORS")
+make_symlink("${CMAKE_SOURCE_DIR}/LICENSE" "${CMAKE_BINARY_DIR}/Server/LICENSE")
+make_symlink("${CMAKE_SOURCE_DIR}/Server/Install/ThirdPartyLicenses" "${CMAKE_BINARY_DIR}/Server/ThirdPartyLicenses")
-# Make the debug executable have a "_debug" suffix
-SET_TARGET_PROPERTIES(${CMAKE_PROJECT_NAME} PROPERTIES DEBUG_POSTFIX "_debug")
-# Make the profiled executables have a "_profile" postfix
-SET_TARGET_PROPERTIES(${CMAKE_PROJECT_NAME} PROPERTIES DEBUGPROFILE_POSTFIX "_debug_profile")
-SET_TARGET_PROPERTIES(${CMAKE_PROJECT_NAME} PROPERTIES RELEASEPROFILE_POSTFIX "_profile")
# Precompiled headers (2nd part)
@@ -375,9 +434,11 @@ target_link_libraries(${CMAKE_PROJECT_NAME} luaexpat jsoncpp_lib_static mbedtls
# Create a folder for Bindings' documentation:
FILE(MAKE_DIRECTORY "Bindings/docs")
+make_symlink("${CMAKE_SOURCE_DIR}/src/Bindings/docs" "${CMAKE_BINARY_DIR}/Server/BindingsDocs")
-# For MSVC, set the startup project to Cuberite:
+# For MSVC, set the startup project to Cuberite, and the debugger dir:
if (MSVC)
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${CMAKE_PROJECT_NAME})
+ set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/Server")
endif()