Skip to content

Commit

Permalink
Added automatic working directory to CMakeLists.txt script.
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasBanana committed Aug 17, 2023
1 parent 7688940 commit 9561114
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,29 @@ macro(ADD_DEBUG_DEFINE IDENT)
endif(MSVC)
endmacro()

macro(SET_PROJECT_WORKING_DIR TEST_NAME WORKING_DIR)
if(WIN32)
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.8.2")
set_target_properties(${TEST_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${WORKING_DIR}")
endif()
elseif(APPLE)
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.17.5")
set_target_properties(${TEST_NAME} PROPERTIES XCODE_GENERATE_SCHEME TRUE XCODE_SCHEME_WORKING_DIRECTORY "${WORKING_DIR}")
endif()
endif()
endmacro()

macro(SET_EXAMPLE_PROJECT_WORKING_DIR TEST_NAME)
if(${TEST_NAME} MATCHES "Example_+")
string(SUBSTRING ${TEST_NAME} 8 -1 TEST_BASE_NAME)
SET_PROJECT_WORKING_DIR(${TEST_NAME} "${EXAMPLE_PROJECTS_DIR}/${TEST_BASE_NAME}")
elseif(${TEST_NAME} MATCHES "Test_+")
SET_PROJECT_WORKING_DIR(${TEST_NAME} "${PROJECT_SOURCE_DIR}/tests")
elseif(${TEST_NAME} MATCHES "Testbed")
SET_PROJECT_WORKING_DIR(${TEST_NAME} "${PROJECT_SOURCE_DIR}/tests/Testbed")
endif()
endmacro()

macro(ADD_EXAMPLE_PROJECT TEST_NAME TEST_FILES LIB_FILES)
if(APPLE)
add_executable(${TEST_NAME} MACOSX_BUNDLE ${TEST_FILES})
Expand All @@ -97,6 +120,7 @@ macro(ADD_EXAMPLE_PROJECT TEST_NAME TEST_FILES LIB_FILES)
endif()
target_link_libraries(${TEST_NAME} ${LIB_FILES})
set_target_properties(${TEST_NAME} PROPERTIES LINKER_LANGUAGE CXX DEBUG_POSTFIX "D")
SET_EXAMPLE_PROJECT_WORKING_DIR(${TEST_NAME})
endmacro()

macro(ADD_C99_EXAMPLE_PROJECT TEST_NAME TEST_FILES LIB_FILES)
Expand All @@ -107,6 +131,7 @@ macro(ADD_C99_EXAMPLE_PROJECT TEST_NAME TEST_FILES LIB_FILES)
endif()
target_link_libraries(${TEST_NAME} ${LIB_FILES})
set_target_properties(${TEST_NAME} PROPERTIES LINKER_LANGUAGE C DEBUG_POSTFIX "D")
SET_EXAMPLE_PROJECT_WORKING_DIR(${TEST_NAME})
endmacro()

macro(ADD_MOBILE_EXAMPLE_PROJECT TEST_NAME TEST_FILES LIB_FILES)
Expand Down

0 comments on commit 9561114

Please sign in to comment.