Skip to content

Commit

Permalink
Set lib dir to be top level if top level supports IDI's CMake depende…
Browse files Browse the repository at this point in the history
…ncy system
  • Loading branch information
Cliff Foster committed Mar 11, 2024
1 parent 8a93b02 commit 2ccf07d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
21 changes: 19 additions & 2 deletions cmake/idi/functions/framework/idi_init.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,26 @@ macro(idi_init)

idi_new_component()



if(NOT IDICMAKE_IS_SUBDIRECTORY)
set(IDICMAKE_TOP_LEVEL_CMAKE_DEPENDENCY_SUPPORT 1 CACHE BOOL "")
set(IDICMAKE_EXTERNAL_LIB_DIR "${CMAKE_CURRENT_LIST_DIR}/lib/first-party")
set(IDICMAKE_EXTERNAL_THIRD_PARTY_LIB_DIR "${CMAKE_CURRENT_LIST_DIR}/lib/third-party")
else()
if(NOT IDICMAKE_TOP_LEVEL_CMAKE_DEPENDENCY_SUPPORT)
message(STATUS "Top level project does not support the IDI CMake dependency structure, placing dependencies in local lib folder.")
set(IDICMAKE_EXTERNAL_LIB_DIR "${CMAKE_CURRENT_LIST_DIR}/lib/first-party")
set(IDICMAKE_EXTERNAL_THIRD_PARTY_LIB_DIR "${CMAKE_CURRENT_LIST_DIR}/lib/third-party")
else()
set(IDICMAKE_EXTERNAL_LIB_DIR "${CMAKE_SOURCE_DIR}/lib/first-party")
set(IDICMAKE_EXTERNAL_THIRD_PARTY_LIB_DIR "${CMAKE_SOURCE_DIR}/lib/third-party")
endif()
endif()


# Define a nice short hand for 3rd party external library folders
set(IDICMAKE_EXTERNAL_LIB_DIR "${CMAKE_CURRENT_LIST_DIR}/lib/first-party")
set(IDICMAKE_EXTERNAL_THIRD_PARTY_LIB_DIR "${CMAKE_CURRENT_LIST_DIR}/lib/third-party")


idi_add_third_party_dependency(Catch2 https://github.com/catchorg/Catch2.git v3.5.2)

Expand Down
4 changes: 2 additions & 2 deletions cmake/idi/functions/idi_add_dependency.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ function(__idi_add_dependency IDI_DEP_NAME IDI_DEP_URL IDI_DEP_TAG IDI_DEP_THIRD
set(IDI_DO_POPULATE false)

if(IDI_DEP_THIRD_PARTY)
set(IDI_DEP_SOURCE_DIR "${CMAKE_SOURCE_DIR}/lib/third-party/${IDI_DEP_NAME}")
set(IDI_DEP_SOURCE_DIR "${IDICMAKE_EXTERNAL_THIRD_PARTY_LIB_DIR}/${IDI_DEP_NAME}")
set(IDI_DEP_BINARY_DIR "${CMAKE_BINARY_DIR}/_deps/${IDI_DEP_NAME_LOWER}")
if(EXISTS ${IDI_DEP_SOURCE_DIR} AND EXISTS "${IDI_DEP_SOURCE_DIR}/.git")

Expand Down Expand Up @@ -168,7 +168,7 @@ function(__idi_add_dependency IDI_DEP_NAME IDI_DEP_URL IDI_DEP_TAG IDI_DEP_THIRD
set(IDI_DO_POPULATE true)
endif()
else()
set(IDI_DEP_SOURCE_DIR "${CMAKE_SOURCE_DIR}/lib/first-party/${IDI_DEP_NAME}")
set(IDI_DEP_SOURCE_DIR "${IDICMAKE_EXTERNAL_LIB_DIR}/${IDI_DEP_NAME}")
set(IDI_DEP_BINARY_DIR "${CMAKE_BINARY_DIR}/_deps/${IDI_DEP_NAME_LOWER}")
if(EXISTS ${IDI_DEP_SOURCE_DIR} AND EXISTS "${IDI_DEP_SOURCE_DIR}/.git")

Expand Down
5 changes: 5 additions & 0 deletions lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,8 @@ target_include_directories(asio SYSTEM INTERFACE ${IDICMAKE_EXTERNAL_THIRD_PARTY
# Git Submodules

Use git submodules as you would in any other project. Do not place them in the first or third party folders used with the CMake dependency system as they will be ignored and possibly not tracked correctly by git.


# Migration Considerations

If moving from a previous submodule system, it is best to make sure that you go from a top-down approach to migrating. Make sure the root project is updated to accept CMake dependencies, then update any dependencies that may also be using this system.

0 comments on commit 2ccf07d

Please sign in to comment.