Skip to content

Commit

Permalink
refactor(cmake): change output dir to user dir (#39)
Browse files Browse the repository at this point in the history
Signed-off-by: Tony Gorez <[email protected]>
  • Loading branch information
tony-go authored Nov 19, 2024
1 parent f76b85a commit a9e2d8f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ build
.DS_Store
.vs
out
example/*/dist
10 changes: 4 additions & 6 deletions cmake/example.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,18 @@ function(add_example)
if(APPLE)
if(EXAMPLE_TYPE STREQUAL "desktop")
add_custom_target(${EXAMPLE_NAME}_run
COMMAND "${EXAMPLE_BINARY_DIR}/${EXAMPLE_APP_NAME}.app/Contents/MacOS/${EXAMPLE_APP_NAME}"
WORKING_DIRECTORY "${EXAMPLE_BINARY_DIR}"
COMMAND "${EXAMPLE_SOURCE_DIR}/dist/${EXAMPLE_APP_NAME}.app/Contents/MacOS/${EXAMPLE_APP_NAME}"
COMMENT "Running ${EXAMPLE_NAME} example (bundle)")
else()
add_custom_target(${EXAMPLE_NAME}_run
COMMAND "${EXAMPLE_BINARY_DIR}/${EXAMPLE_APP_NAME}" --foo bar
WORKING_DIRECTORY "${EXAMPLE_BINARY_DIR}"
COMMAND "${EXAMPLE_SOURCE_DIR}/dist/${EXAMPLE_APP_NAME}" --foo bar
COMMENT "Running ${EXAMPLE_NAME} example (executable)")
endif()
add_dependencies(${EXAMPLE_NAME}_run ${EXAMPLE_NAME}_build)
elseif(WIN32)
add_custom_target(${EXAMPLE_NAME}_run
COMMAND "${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE_NAME}/$<CONFIG>/${EXAMPLE_APP_NAME}.exe"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE_NAME}/$<CONFIG>"
COMMAND "${EXAMPLE_SOURCE_DIR}/dist/$<CONFIG>/${EXAMPLE_APP_NAME}.exe"
WORKING_DIRECTORY "${EXAMPLE_SOURCE_DIR}/dist/$<CONFIG>"
COMMENT "Running ${EXAMPLE_NAME} example (Windows)")
add_dependencies(${EXAMPLE_NAME}_run ${EXAMPLE_NAME}_build)
endif()
Expand Down
4 changes: 3 additions & 1 deletion cmake/native.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
function(native_add_app)
cmake_parse_arguments(NATIVE "" "TARGET;PLATFORM" "ASSETS" ${ARGN})

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/dist")

if(APPLE)
_native_add_app_apple(${ARGN})
elseif(WIN32)
Expand Down Expand Up @@ -281,7 +283,7 @@ function(_native_add_assets_win32)
add_custom_command(
TARGET ${NATIVE_TARGET}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/${asset} ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${asset}
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/${asset} ${CMAKE_SOURCE_DIR}/dist/$<CONFIG>/${asset}
COMMENT "Copying asset: ${asset} \n"
)
endforeach()
Expand Down

0 comments on commit a9e2d8f

Please sign in to comment.