Skip to content

Commit

Permalink
chore(build): fix error using find_package with ExternalProject_Add
Browse files Browse the repository at this point in the history
Signed-off-by: Federico Aponte <[email protected]>
  • Loading branch information
federico-sysdig authored and poiana committed Dec 11, 2023
1 parent 5e17ba6 commit e427c80
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 6 additions & 1 deletion cmake/modules/njson.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ if(USE_BUNDLED_NLOHMANN_JSON)
ExternalProject_Add(njson
URL "https://github.com/nlohmann/json/archive/v3.3.0.tar.gz"
URL_HASH "SHA256=2fd1d207b4669a7843296c41d3b6ac5b23d00dec48dba507ba051d14564aa801"
CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release -DJSON_BuildTests=OFF -DBUILD_TESTING=OFF
CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${PROJECT_BINARY_DIR}/njson-prefix -DJSON_BuildTests=OFF -DBUILD_TESTING=OFF
)

set(nlohmann_json_DIR ${PROJECT_BINARY_DIR}/njson-prefix/include)
else()
find_package(nlohmann_json CONFIG REQUIRED)
add_custom_target(njson)
endif()
6 changes: 2 additions & 4 deletions userspace/engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.

find_package(nlohmann_json CONFIG REQUIRED)

add_library(falco_engine STATIC
falco_common.cpp
falco_engine.cpp
Expand All @@ -34,19 +32,19 @@ if (EMSCRIPTEN)
target_compile_options(falco_engine PRIVATE "-sDISABLE_EXCEPTION_CATCHING=0")
endif()

add_dependencies(falco_engine yamlcpp)
add_dependencies(falco_engine yamlcpp njson)

target_include_directories(falco_engine
PUBLIC
${LIBSCAP_INCLUDE_DIRS}
${LIBSINSP_INCLUDE_DIRS}
${PROJECT_BINARY_DIR}/userspace/engine
${nlohmann_json_DIR}
${TBB_INCLUDE_DIR}
${YAMLCPP_INCLUDE_DIR}
)

target_link_libraries(falco_engine
nlohmann_json::nlohmann_json
${FALCO_SINSP_LIBRARY}
${YAMLCPP_LIB}
)

0 comments on commit e427c80

Please sign in to comment.