Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions engine/src/scripting/managed/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ cmake_minimum_required(VERSION 3.20)
project(nexoManaged LANGUAGES NONE)

# Define variables for configuration
set(NEXO_MANAGED_OUTPUT_DIR ${CMAKE_BINARY_DIR})
file(RELATIVE_PATH NEXO_MANAGED_OUTPUT_DIR_REL "${CMAKE_CURRENT_LIST_DIR}" "${NEXO_MANAGED_OUTPUT_DIR}")
set(NEXO_FRAMEWORK "net9.0")

set(SOURCES
Expand Down Expand Up @@ -63,21 +61,22 @@ else()
endif()


# Build step
# Build step with OutputPath passed as parameter to support multi-config builds
add_custom_target(nexoManaged ALL
COMMAND ${DOTNET_EXECUTABLE} build Nexo.csproj
${ARCH_ARG}
-c $<CONFIG> # Matches Debug/Release configuration
/p:OutputPath=${CMAKE_BINARY_DIR}/ # Pass OutputPath dynamically based on build directory
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} # Working directory for the build
COMMENT "Building .NET managed project (Nexo.csproj)..."
COMMENT "Building .NET managed project (Nexo.csproj) for $<CONFIG> configuration..."
)
Comment on lines +64 to 72
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Critical: OutputPath doesn't separate configurations for multi-config generators.

The OutputPath is set to ${CMAKE_BINARY_DIR}/ without including the configuration subdirectory. For multi-config generators (Visual Studio, Ninja Multi-Config), Debug and Release builds will output to the same directory and overwrite each other's artifacts.

Apply this diff to properly separate configurations:

-                  /p:OutputPath=${CMAKE_BINARY_DIR}/  # Pass OutputPath dynamically based on build directory
+                  /p:OutputPath=${CMAKE_BINARY_DIR}/$<CONFIG>/  # Pass OutputPath dynamically with config subdirectory

This ensures each configuration (Debug/Release/etc.) outputs to its own subdirectory (e.g., build/Debug/, build/Release/), preventing artifacts from overwriting each other in multi-config builds.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Build step with OutputPath passed as parameter to support multi-config builds
add_custom_target(nexoManaged ALL
COMMAND ${DOTNET_EXECUTABLE} build Nexo.csproj
${ARCH_ARG}
-c $<CONFIG> # Matches Debug/Release configuration
/p:OutputPath=${CMAKE_BINARY_DIR}/ # Pass OutputPath dynamically based on build directory
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} # Working directory for the build
COMMENT "Building .NET managed project (Nexo.csproj)..."
COMMENT "Building .NET managed project (Nexo.csproj) for $<CONFIG> configuration..."
)
# Build step with OutputPath passed as parameter to support multi-config builds
add_custom_target(nexoManaged ALL
COMMAND ${DOTNET_EXECUTABLE} build Nexo.csproj
${ARCH_ARG}
-c $<CONFIG> # Matches Debug/Release configuration
/p:OutputPath=${CMAKE_BINARY_DIR}/$<CONFIG>/ # Pass OutputPath dynamically with config subdirectory
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} # Working directory for the build
COMMENT "Building .NET managed project (Nexo.csproj) for $<CONFIG> configuration..."
)
🤖 Prompt for AI Agents
In engine/src/scripting/managed/CMakeLists.txt around lines 64 to 72, OutputPath
is set to ${CMAKE_BINARY_DIR}/ which causes different configurations to write to
the same folder; change the OutputPath to include the configuration subdirectory
so multi-config generators separate outputs (for example set
/p:OutputPath=${CMAKE_BINARY_DIR}/$<CONFIG>/ or equivalent) so
Debug/Release/etc. produce isolated build directories and avoid overwriting
artifacts.


# Clean step
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_CLEAN_FILES
${NEXO_MANAGED_OUTPUT_DIR}/Nexo.dll
${NEXO_MANAGED_OUTPUT_DIR}/Nexo.pdb
${NEXO_MANAGED_OUTPUT_DIR}/Nexo.runtimeconfig.json
${NEXO_MANAGED_OUTPUT_DIR}/Nexo.deps.json
${CMAKE_BINARY_DIR}/Nexo.dll
${CMAKE_BINARY_DIR}/Nexo.pdb
${CMAKE_BINARY_DIR}/Nexo.runtimeconfig.json
${CMAKE_BINARY_DIR}/Nexo.deps.json
${CMAKE_CURRENT_LIST_DIR}/obj
${CMAKE_CURRENT_LIST_DIR}/bin
)
9 changes: 3 additions & 6 deletions engine/src/scripting/managed/Nexo.csproj.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,13 @@
<EnableDynamicLoading>true</EnableDynamicLoading>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<!-- OutputPath is passed via command line from CMake to support multi-config builds -->
</PropertyGroup>

<ItemGroup>
<Compile Include="@SOURCES@" />
</ItemGroup>

<PropertyGroup>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<OutputPath>@NEXO_MANAGED_OUTPUT_DIR_REL@</OutputPath>
</PropertyGroup>

</Project>
Loading