1- macro (add_package name url tag option )
1+ macro (add_package name url tag patch option )
22 string (ASCII 27 Esc)
33 set (ColorReset "${Esc} [m" )
44 set (Yellow "${Esc} [33m" )
@@ -9,30 +9,34 @@ macro(add_package name url tag option)
99 string (TOUPPER ${name} nameu)
1010 option (${nameu} "Build ${name} " ${option} )
1111
12- if (${nameu} )
12+ if (${${ nameu} })
1313 if (EXISTS ${CACHE_FILE} )
14- if (NOT EXISTS ${CMAKE_BINARY_DIR} /_deps/${name} -src)
15- message (
16- STATUS "${Yellow} Find cached file ${name} -${tag} .tar.gz${ColorReset} " )
17- execute_process (COMMAND tar -xzf ${CACHE_FILE} -C ${CACHE_DIR} )
18- execute_process (COMMAND mv ${CACHE_DIR} /${name}-src
19- ${CMAKE_BINARY_DIR} /_deps/ )
14+ if (NOT EXISTS ${CMAKE_BINARY_DIR} /_deps)
15+ file (MAKE_DIRECTORY ${CMAKE_BINARY_DIR} /_deps )
2016 endif ()
2117
22- FetchContent_Declare (${name} SOURCE_DIR
23- ${CMAKE_BINARY_DIR} /_deps/${name} -src)
18+ message (
19+ STATUS
20+ "${Yellow} Using cached library ${name} -${tag} .tar.gz${ColorReset} " )
21+
22+ FetchContent_Declare (${name} DOWNLOAD_COMMAND tar -xzf ${CACHE_FILE} -C
23+ ${CMAKE_BINARY_DIR} /_deps)
2424 else ()
2525 FetchContent_Declare (
2626 ${name}
2727 GIT_REPOSITORY ${url}
28- GIT_TAG ${tag} )
28+ GIT_TAG ${tag}
29+ PATCH_COMMAND ${patch}
30+ UPDATE_DISCONNECTED TRUE )
2931 endif ()
3032
3133 FetchContent_MakeAvailable (${name} )
3234 include_directories (${${name}_SOURCE_DIR} )
3335
3436 if (NOT EXISTS ${CACHE_FILE} )
35- message (STATUS "Creating ${CACHE_FILE} " )
37+ message (
38+ STATUS
39+ "${Yellow} Creating cached library ${name} -${tag} .tar.gz${ColorReset} " )
3640 execute_process (COMMAND tar -czf ${CACHE_DIR} /${name}-${tag}.tar.gz -C
3741 ${CMAKE_BINARY_DIR} /_deps ${name} -src )
3842 endif ()
0 commit comments