Skip to content

Commit bb303ca

Browse files
committed
[CMake] Use target property RUNTIME_OUTPUT_DIRECTORY instead of overriding CMake variables (fixes #158).
This uses the aforementioned target property in CMakeLists.txt instead of overriding EXECUTABLE_OUTPUT_PATH and LIBRARY_OUTPUT_PATH. Doing so limits the output directory to LLGL and its example/test projects instead of interfering with other projects that might use LLGL as a sub-project.
1 parent aa424da commit bb303ca

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

CMakeLists.txt

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@ endif()
7676

7777
# === Build path ===
7878

79-
set(OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/build)
80-
set(EXECUTABLE_OUTPUT_PATH ${OUTPUT_DIR} CACHE PATH "Build directory" FORCE)
81-
set(LIBRARY_OUTPUT_PATH ${OUTPUT_DIR} CACHE PATH "Build directory" FORCE)
79+
set(LLGL_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/build)
8280

8381
set( EXTERNAL_MODULE_DIR "${PROJECT_SOURCE_DIR}/cmake" )
8482
set( PROJECT_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/include" )
@@ -225,9 +223,10 @@ endfunction()
225223
function(set_llgl_module_properties MODULE_NAME)
226224
set_target_properties(
227225
${MODULE_NAME} PROPERTIES
228-
LINKER_LANGUAGE CXX
229-
DEBUG_POSTFIX "D"
230-
FOLDER "LLGL"
226+
LINKER_LANGUAGE CXX
227+
DEBUG_POSTFIX "D"
228+
FOLDER "LLGL"
229+
RUNTIME_OUTPUT_DIRECTORY "${LLGL_OUTPUT_DIR}"
231230
)
232231
endfunction()
233232

@@ -348,14 +347,21 @@ function(add_llgl_example_project PROJECT_NAME LINKER_LANG SRC_FILES LIB_FILES)
348347
target_link_libraries(${PROJECT_NAME} ${LIB_FILES})
349348
endif()
350349

350+
# Configure base properties for example project
351+
set_target_properties(
352+
${PROJECT_NAME} PROPERTIES
353+
DEBUG_POSTFIX "D"
354+
RUNTIME_OUTPUT_DIRECTORY "${LLGL_OUTPUT_DIR}"
355+
)
356+
351357
# Configure linker settings
352358
if(LLGL_ANDROID_PLATFORM)
353359
# When linking the libExample*.so library for Android, we link with C++ semantics.
354360
# Otherwise, the libc++_shared.so library will be unintentionally included,
355361
# since the static dependencies like libLLGL.so must be build with C++, regardingless of the example project's language
356-
set_target_properties(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE CXX DEBUG_POSTFIX "D")
362+
set_target_properties(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE CXX)
357363
else()
358-
set_target_properties(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE ${LINKER_LANG} DEBUG_POSTFIX "D")
364+
set_target_properties(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE ${LINKER_LANG})
359365
endif()
360366

361367
# Configure working directory and project solution folder

0 commit comments

Comments
 (0)