MSVC: Build all binaries directly in build dir

With this change, MSVC will build binaries in ${CMAKE_CURRENT_BINARY_DIR}
without adding any more subdirectories. It will also expect its data in a
directory called "planet" immediately below the binary directory.
Since MSVC allows building multiple configurations from the same input file,
the resulting binaries will be suffixed by the configuration type. An exception
is RelWithDebInfo, which will have no suffix; this was chosen over plain Release
to aid in debugging.

Building OpenClonk will work out of the box for in-source builds, but
out-of-source builds will have to create a symlink or a directory junction.
We consider this an acceptable drawback; it was proposed that if you use the
non-default option of an out-of-tree build, you will also know how to create a
link or a junction to, or copy the planet directory.

This changeset also revives looking for game data in the same directory as the
binary, which was part of c3fc1ee1ec8c [Peter Wortmann].
Nicolas Hake 2011-11-10 02:01:21 +01:00
parent 74620be240
commit 0dcfe72148
2 changed files with 24 additions and 11 deletions

View File

@ -41,7 +41,7 @@ separate_arguments(OC_EXE_LINKER_FLAGS_DEBUG)
############################################################################
# User selectable options
############################################################################
option(PROJECT_FOLDERS "Put source files into subfolders in project file" ON)
option(PROJECT_FOLDERS "Put source files into subfolders in project file" ON)
option(USE_GL "Enable OpenGL support" ON)
SET(INITIAL_USE_SDL_MAINLOOP_VALUE OFF)
SET(INITIAL_USE_OPEN_AL OFF)
@ -864,7 +864,6 @@ endif()
############################################################################
# Generate output files
############################################################################
add_definitions(-DHAVE_CONFIG_H)
add_executable(clonk WIN32 MACOSX_BUNDLE
${OC_SYSTEM_SOURCES}
@ -993,6 +992,24 @@ endif()
# expand a second time, using the same syntax. Try not to get confused by this!
set_target_properties(clonk PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/src/res/Info.plist")
if(MSVC)
# set target output filenames to a per-configuration value
function(oc_set_target_names target_name)
foreach(CONFIG ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER "${CONFIG}" CONFIG_UPPER)
string(TOLOWER "${CONFIG}" CONFIG_LOWER)
set_target_properties(${target_name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_${CONFIG_UPPER} "${CMAKE_CURRENT_BINARY_DIR}")
if(NOT "${CONFIG}" STREQUAL "RelWithDebInfo")
set_target_properties(${target_name} PROPERTIES RUNTIME_OUTPUT_NAME_${CONFIG_UPPER} "${target_name}-${CONFIG_LOWER}")
endif()
endforeach()
endfunction()
oc_set_target_names(clonk)
oc_set_target_names(c4group)
oc_set_target_names(c4script)
oc_set_target_names(netpuncher)
endif()
############################################################################
# Precompiled header support, part 2 (post-target)
############################################################################
@ -1244,8 +1261,8 @@ foreach(group ${OC_C4GROUPS})
)
else()
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${group}
COMMAND ${C4GROUP_LOCATION} ${CMAKE_CURRENT_SOURCE_DIR}/planet/${group} -t ${CMAKE_CURRENT_BINARY_DIR}/${group}
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${group}"
COMMAND c4group ARGS "${CMAKE_CURRENT_SOURCE_DIR}/planet/${group}" -t "${CMAKE_CURRENT_BINARY_DIR}/${group}"
MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/planet/${group}
DEPENDS c4group
VERBATIM

View File

@ -27,16 +27,12 @@ void C4Reloc::Init()
{
Paths.clear();
// Check for system group at EXE path - only add if found
if (FileExists(Config.AtExePath(C4CFN_System)))
AddPath(Config.General.ExePath.getData());
#ifndef __APPLE__
StdCopyStrBuf planet(Config.General.ExePath);
planet.AppendBackslash();
#ifdef CMAKE_INTDIR
if (!SEqual(CMAKE_INTDIR, "."))
{
planet.Append("..");
planet.AppendBackslash();
}
#endif
planet.Append("planet");
AddPath(planet.getData());
#endif