Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 27 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ set(LBUG_SOURCE_DIR "" CACHE PATH "Path to the Ladybug source tree used for stan
set(LBUG_BUILD_DIR "" CACHE PATH "Path to the Ladybug build tree used for standalone Node.js builds")
set(LBUG_NODEJS_EXTRA_LINK_LIBS "" CACHE STRING "Additional link libraries for standalone Node.js builds against a precompiled liblbug")

function(lbug_nodejs_set_default_dir out_var suffix)
foreach(base_dir IN ITEMS "${LBUG_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/../.." "${CMAKE_CURRENT_SOURCE_DIR}/../ladybug")
if(base_dir AND EXISTS "${base_dir}/${suffix}")
set(${out_var} "${base_dir}/${suffix}" PARENT_SCOPE)
return()
endif()
endforeach()
set(${out_var} "" PARENT_SCOPE)
endfunction()

# If on Windows use npx.cmd instead of npx
if(WIN32)
set(NPX_CMD npx.cmd)
Expand Down Expand Up @@ -115,15 +125,25 @@ if(NOT TARGET lbug)
message(FATAL_ERROR "Precompiled liblbug archive not found: ${LBUG_NODEJS_PRECOMPILED_LIB_PATH}")
endif()

set(LBUG_NODEJS_SOURCE_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/src/include")
set(LBUG_NODEJS_BUILD_INCLUDE_DIR "${PROJECT_BINARY_DIR}/src/include")
if(LBUG_SOURCE_DIR)
set(LBUG_NODEJS_SOURCE_INCLUDE_DIR "${LBUG_SOURCE_DIR}/src/include")
endif()
if(LBUG_BUILD_DIR)
lbug_nodejs_set_default_dir(LBUG_NODEJS_SOURCE_INCLUDE_DIR "src/include")
set(LBUG_NODEJS_BUILD_INCLUDE_DIR "")
if(LBUG_BUILD_DIR AND EXISTS "${LBUG_BUILD_DIR}/src/include")
set(LBUG_NODEJS_BUILD_INCLUDE_DIR "${LBUG_BUILD_DIR}/src/include")
elseif(LBUG_SOURCE_DIR)
elseif(LBUG_SOURCE_DIR AND EXISTS "${LBUG_SOURCE_DIR}/build/release/src/include")
set(LBUG_NODEJS_BUILD_INCLUDE_DIR "${LBUG_SOURCE_DIR}/build/release/src/include")
elseif(EXISTS "${CMAKE_BINARY_DIR}/src/include")
set(LBUG_NODEJS_BUILD_INCLUDE_DIR "${CMAKE_BINARY_DIR}/src/include")
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../build/release/src/include")
set(LBUG_NODEJS_BUILD_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../build/release/src/include")
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../ladybug/build/release/src/include")
set(LBUG_NODEJS_BUILD_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../ladybug/build/release/src/include")
endif()

if(NOT LBUG_NODEJS_SOURCE_INCLUDE_DIR)
message(FATAL_ERROR "Could not determine the Ladybug source include directory. Set LBUG_SOURCE_DIR to a Ladybug checkout.")
endif()
if(NOT LBUG_NODEJS_BUILD_INCLUDE_DIR)
message(FATAL_ERROR "Could not determine the Ladybug build include directory. Set LBUG_BUILD_DIR or LBUG_SOURCE_DIR to a built Ladybug tree.")
endif()

add_library(lbug STATIC IMPORTED GLOBAL)
Expand Down
Loading