Skip to content

Commit

Permalink
cmake: add option ORC_DOWNLOADS_ONLY
Browse files Browse the repository at this point in the history
  • Loading branch information
fabienfl authored and fabienfl-orc committed Jul 31, 2020
1 parent facae2d commit 2ad1535
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 23 deletions.
12 changes: 11 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ option(ORC_BUILD_PARQUET "Build Parquet module" OFF)
option(ORC_BUILD_SQL "Build SQL module" OFF)
option(ORC_BUILD_SSDEEP "Build with ssdeep support" OFF)
option(ORC_BUILD_JSON "Build with JSON StructuredOutput enabled" ON)
option(ORC_DOWNLOADS_ONLY "Do not build ORC but only download vcpkg third parties" OFF)

if(NOT ORC_BUILD_COMMAND)
set(ORC_BUILD_FASTFIND OFF)
Expand Down Expand Up @@ -108,9 +109,14 @@ if(ORC_VCPKG_ROOT)
list(APPEND _PACKAGES ssdeep)
endif()

if(ORC_DOWNLOADS_ONLY)
set(ONLY_DOWNLOADS "ONLY_DOWNLOADS")
endif()

include(cmake/vcpkg.cmake)
if(ORC_BUILD_VCPKG)
if(ORC_BUILD_VCPKG OR ORC_DOWNLOADS_ONLY)
vcpkg_install(
${ONLY_DOWNLOADS}
PATH ${ORC_VCPKG_ROOT}
PACKAGES ${_PACKAGES}
ARCH ${TARGET_ARCH}
Expand All @@ -120,6 +126,10 @@ if(ORC_VCPKG_ROOT)
endif()
endif()

if(ORC_DOWNLOADS_ONLY)
return()
endif()

# Must be set AFTER 'VCPKG_TARGET_TRIPLET' is defined
project(dfir-orc LANGUAGES C CXX ASM_MASM)

Expand Down
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,25 @@ cmake --build . --config MinSizeRel -- -maxcpucount


### Options
Using default options is recommended with the exception of `ORC_BUILD_VCPKG` which should be set to **ON** so dependencies will be built automatically using vcpkg.

| CMake option | Default | Description |
|:---------------------|:----------------------|:------------------------------|
| ORC_BUILD_VCPKG | ON | Build vcpkg dependencies |
| ORC_BUILD_APACHE_ORC | OFF | Build Apache Orc module |
| ORC_BUILD_CHAKRACORE | OFF | Build with ChakraCore support |
| ORC_BUILD_COMMAND | ON | Build OrcCommand library |
| ORC_BUILD_FASTFIND | OFF | Build FastFind binary |
| ORC_BUILD_ORC | ON | Build Orc binary |
| ORC_BUILD_PARQUET | OFF | Build Parquet module (x64) |
| ORC_BUILD_SQL | OFF | Build SQL module [1] |
| ORC_BUILD_SSDEEP | OFF | Build with ssdeep support |
| ORC_BUILD_JSON | ON | Build with JSON enabled |
| ORC_USE_STATIC_CRT | ON | Use static runtime |
| ORC_VCPKG_ROOT | ${ORC}/external/vcpkg | VCPKG root directory |
| ORC_XMLLITE_PATH | | XmlLite.dll path (xp sp2) |
| VCPKG_TARGET_TRIPLET | Autodetect | VCPKG triplet to use |
| CMAKE_TOOLCHAIN_FILE | Autodetect | VCPKG's toolchain file |

| CMake option | Default | Description |
|:---------------------|:----------------------|:---------------------------------|
| ORC_DOWNLOADS_ONLY | OFF | Only download vcpkg dependencies |
| ORC_BUILD_VCPKG | ON | Build vcpkg dependencies |
| ORC_BUILD_APACHE_ORC | OFF | Build Apache Orc module |
| ORC_BUILD_CHAKRACORE | OFF | Build with ChakraCore support |
| ORC_BUILD_COMMAND | ON | Build OrcCommand library |
| ORC_BUILD_FASTFIND | OFF | Build FastFind binary |
| ORC_BUILD_ORC | ON | Build Orc binary |
| ORC_BUILD_PARQUET | OFF | Build Parquet module (x64) |
| ORC_BUILD_SQL | OFF | Build SQL module [1] |
| ORC_BUILD_SSDEEP | OFF | Build with ssdeep support |
| ORC_BUILD_JSON | ON | Build with JSON enabled |
| ORC_USE_STATIC_CRT | ON | Use static runtime |
| ORC_VCPKG_ROOT | ${ORC}/external/vcpkg | VCPKG root directory |
| ORC_XMLLITE_PATH | | XmlLite.dll path (xp sp2) |
| VCPKG_TARGET_TRIPLET | Autodetect | VCPKG triplet to use |
| CMAKE_TOOLCHAIN_FILE | Autodetect | VCPKG's toolchain file |


[1] `ORC_BUILD_SQL=ON` requires [SQL Server Native Client](https://docs.microsoft.com/en-us/sql/relational-databases/native-client/applications/installing-sql-server-native-client?view=sql-server-2017)
Expand Down
17 changes: 14 additions & 3 deletions cmake/vcpkg.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,13 @@ endfunction()
# PACKAGES list list of packages to be installed
# ARCH x86/x64 build architecture
# USE_STATIC_CRT ON/OFF use static runtime
# ONLY_DOWNLOADS <option> only download dependencies
#
# RESULT
# VCPKG_PACKAGES_FOUND BOOL TRUE if pacakges are found
#
function(vcpkg_install_packages)
set(OPTIONS)
set(OPTIONS ONLY_DOWNLOADS)
set(SINGLE PATH ARCH USE_STATIC_CRT)
set(MULTI PACKAGES OVERLAY_PORTS OVERLAY_TRIPLETS)

Expand Down Expand Up @@ -100,8 +101,12 @@ function(vcpkg_install_packages)
"install ${PACKAGES_STR}\n"
)

if(VCPKG_ONLY_DOWNLOADS)
set(ONLY_DOWNLOADS "--only-downloads")
endif()

execute_process(
COMMAND "vcpkg.exe" --vcpkg-root ${VCPKG_PATH} ${OVERLAY_PORTS_STR} ${OVERLAY_TRIPLETS_STR} install ${PACKAGES}
COMMAND "vcpkg.exe" --vcpkg-root ${VCPKG_PATH} ${OVERLAY_PORTS_STR} ${OVERLAY_TRIPLETS_STR} install ${ONLY_DOWNLOADS} ${PACKAGES}
WORKING_DIRECTORY ${VCPKG_PATH}
RESULT_VARIABLE RESULT
)
Expand Down Expand Up @@ -167,14 +172,15 @@ endfunction()
# USE_STATIC_CRT ON/OFF use static runtime
# OVERLAY_PORTS path list of overlay directories
# NO_UPGRADE <option> do not upgrade
# ONLY_DOWNLOADS <option> only download packages
#
# RESULT
# VCPKG_FOUND BOOL TRUE if vcpkg is found and setup
# CMAKE_TOOLCHAIN_FILE path vcpkg toolchain
# VCPKG_TARGET_TRIPLET triplet triplet to use
#
function(vcpkg_install)
set(OPTIONS NO_UPGRADE)
set(OPTIONS NO_UPGRADE ONLY_DOWNLOADS)
set(SINGLE PATH ARCH USE_STATIC_CRT)
set(MULTI PACKAGES OVERLAY_PORTS OVERLAY_TRIPLETS)

Expand All @@ -192,7 +198,12 @@ function(vcpkg_install)
)
endif()

if(VCPKG_ONLY_DOWNLOADS)
set(ONLY_DOWNLOADS "ONLY_DOWNLOADS")
endif()

vcpkg_install_packages(
${ONLY_DOWNLOADS}
PATH ${VCPKG_PATH}
OVERLAY_PORTS ${VCPKG_OVERLAY_PORTS}
OVERLAY_TRIPLETS ${VCPKG_OVERLAY_TRIPLETS}
Expand Down

0 comments on commit 2ad1535

Please sign in to comment.