carla/Unreal/CMakeLists.txt

206 lines
3.6 KiB
CMake
Raw Normal View History

project (
carla-ue
)
set (
CARLA_UE_PATH
2024-03-04 20:33:51 +08:00
${CARLA_WORKSPACE_PATH}/Unreal/CarlaUnreal
)
2024-03-07 00:20:13 +08:00
set (
CARLA_UE_PLUGINS_PATH
${CARLA_UE_PATH}/Plugins
)
set (
CARLA_UE_PROJECT_PATH
2024-03-04 20:33:51 +08:00
${CARLA_UE_PATH}/CarlaUnreal.uproject
)
if (WIN32)
set (
2024-03-11 19:30:24 +08:00
CARLA_UE_GENERATE_PROJECT_FILES_COMMAND
${CARLA_UNREAL_ENGINE_PATH}/GenerateProjectFiles.bat
2024-03-11 19:30:24 +08:00
-project=${CARLA_UE_PROJECT_PATH}
-CMakefile
-game
-engine
2024-03-12 18:01:37 +08:00
-progress
)
else ()
set (
2024-03-11 19:30:24 +08:00
CARLA_UE_GENERATE_PROJECT_FILES_COMMAND
${CARLA_UNREAL_ENGINE_PATH}/GenerateProjectFiles.sh
2024-03-11 19:30:24 +08:00
-project=${CARLA_UE_PROJECT_PATH}
-CMakefile
-game
-engine
2024-03-12 18:01:37 +08:00
-progress
)
endif ()
2024-03-12 18:01:37 +08:00
set (CMAKE_NINJA_FORCE_RESPONSE_FILE ON)
2024-03-07 00:20:13 +08:00
2024-03-08 00:11:15 +08:00
add_custom_command (
2024-03-12 18:01:37 +08:00
OUTPUT
${CARLA_UE_PATH}/CMakeLists.txt
2024-03-07 00:20:13 +08:00
COMMENT
"Generating UE project files for CARLA..."
COMMAND
2024-03-11 19:30:24 +08:00
${CARLA_UE_GENERATE_PROJECT_FILES_COMMAND}
# Remember to add this on most Unreal-related commands,
# otherwise nothing is printed while running the command:
USES_TERMINAL
2024-03-12 18:01:37 +08:00
VERBATIM
)
2024-03-07 00:20:13 +08:00
add_custom_target (
2024-03-08 00:11:15 +08:00
carla-ue-generate-project-files
2024-03-11 19:30:24 +08:00
DEPENDS
${CARLA_UE_PATH}/CMakeLists.txt
2024-03-08 00:11:15 +08:00
)
2024-03-12 18:01:37 +08:00
add_dependencies (
carla-ue-generate-project-files
carla-server
)
if (CMAKE_TOOLCHAIN_FILE)
cmake_path (
ABSOLUTE_PATH CMAKE_TOOLCHAIN_FILE
BASE_DIRECTORY ${CARLA_WORKSPACE_PATH}
NORMALIZE
OUTPUT_VARIABLE TOOLCHAIN_FILE
)
set (TOOLCHAIN_FILE_OPTION --toolchain=${TOOLCHAIN_FILE})
else ()
set (TOOLCHAIN_FILE_OPTION)
endif ()
2024-03-08 00:11:15 +08:00
add_custom_command (
2024-03-12 18:01:37 +08:00
OUTPUT
${CMAKE_CURRENT_BINARY_DIR}/carla-ue-configure.stamp
2024-03-08 00:11:15 +08:00
COMMENT
"Configuring Carla Unreal..."
COMMAND
2024-03-11 19:30:24 +08:00
${CMAKE_COMMAND}
-S ${CARLA_UE_PATH}
-B ${CMAKE_CURRENT_BINARY_DIR}
${TOOLCHAIN_FILE_OPTION}
2024-03-08 00:11:15 +08:00
COMMAND
${CMAKE_COMMAND}
2024-03-11 19:30:24 +08:00
-E touch carla-ue-configure.stamp
USES_TERMINAL
2024-03-12 18:01:37 +08:00
VERBATIM
2024-03-08 00:11:15 +08:00
)
add_custom_target (
carla-ue-configure
2024-03-07 00:20:13 +08:00
DEPENDS
2024-03-08 00:11:15 +08:00
carla-ue-configure.stamp
)
2024-03-12 18:01:37 +08:00
add_dependencies (
carla-ue-configure
carla-ue-generate-project-files
)
2024-03-08 00:11:15 +08:00
add_custom_command (
2024-03-12 18:01:37 +08:00
OUTPUT
${CMAKE_CURRENT_BINARY_DIR}/carla-ue.stamp
2024-03-07 00:20:13 +08:00
COMMENT
2024-03-08 00:11:15 +08:00
"Building Carla Unreal..."
2024-03-07 00:20:13 +08:00
COMMAND
${CMAKE_COMMAND}
2024-03-08 00:11:15 +08:00
--build ${CMAKE_CURRENT_BINARY_DIR}
--target CarlaUnrealEditor
2024-03-11 19:30:24 +08:00
COMMAND
${CMAKE_COMMAND}
-E touch carla-ue.stamp
USES_TERMINAL
2024-03-12 18:01:37 +08:00
VERBATIM
2024-03-08 00:11:15 +08:00
)
add_custom_target (
carla-ue
DEPENDS
carla-ue.stamp
2024-03-07 00:20:13 +08:00
)
2024-03-12 18:01:37 +08:00
add_dependencies (
carla-ue
carla-ue-configure
)
2024-03-11 16:20:27 +08:00
if (WIN32)
set (EXE_EXT .exe)
else ()
set (EXE_EXT)
endif ()
2024-03-11 16:13:55 +08:00
if (WIN32)
set (UE_SYSTEM_NAME Win64)
elseif (LINUX)
set (UE_SYSTEM_NAME Linux)
else ()
endif ()
add_custom_target (
launch-only
2024-03-12 18:01:37 +08:00
COMMENT
"Launching Carla Unreal..."
COMMAND
2024-03-11 16:20:27 +08:00
${CARLA_UNREAL_ENGINE_PATH}/Engine/Binaries/${UE_SYSTEM_NAME}/UnrealEditor${EXE_EXT}
2024-03-11 19:30:24 +08:00
${CARLA_UE_PROJECT_PATH}
-${CARLA_UNREAL_RHI}
${LAUNCH_ARGS}
USES_TERMINAL
2024-03-12 18:01:37 +08:00
VERBATIM
)
add_custom_target (
launch
2024-03-12 18:01:37 +08:00
COMMENT
"Launching Carla Unreal..."
COMMAND
${CARLA_UNREAL_ENGINE_PATH}/Engine/Binaries/${UE_SYSTEM_NAME}/UnrealEditor${EXE_EXT}
${CARLA_UE_PROJECT_PATH}
-${CARLA_UNREAL_RHI}
${LAUNCH_ARGS}
USES_TERMINAL
VERBATIM
)
add_dependencies (
launch
carla-ue
)
file (
MAKE_DIRECTORY
${CARLA_UE_PATH}/Content/Carla/ExportedMaps
)
carla_two_step_configure_file (
${CARLA_UE_PLUGINS_PATH}/Carla/Source/Carla/Carla.Build.cs
${CARLA_UE_PLUGINS_PATH}/Carla/Source/Carla/Carla.Build.cs.in
)
carla_two_step_configure_file (
${CARLA_UE_PLUGINS_PATH}/CarlaTools/Source/CarlaTools/CarlaTools.Build.cs
${CARLA_UE_PLUGINS_PATH}/CarlaTools/Source/CarlaTools/CarlaTools.Build.cs.in
)