Skip to content

Commit

Permalink
Enable VCPKG Integration (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
ls-1801 authored Aug 12, 2024
1 parent 428a84f commit ce6b2df
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 13 deletions.
23 changes: 17 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ option(ENABLE_LOGGING "Enable logging support" ON)
option(ENABLE_STACKTRACE "Enable stacktrace support" ON)
option(ENABLE_TESTS "Enable tests" ON)
option(ENABLE_COMPILER "Enables tracing and backend compilers" ON)
option(USE_EXTERNAL_SPDLOG "Use a externally provided version of spdlog" OFF)
option(USE_EXTERNAL_MLIR "Use a externally provided version of MLIR" OFF)
cmake_dependent_option(ENABLE_TRACING "Enable the tracing" ON "ENABLE_COMPILER" OFF)
cmake_dependent_option(ENABLE_MLIR_BACKEND "Enable the MLIR compiler backend" ON "ENABLE_COMPILER" OFF)
cmake_dependent_option(NAUTILUS_DOWNLOAD_MLIR "USE_PRE_BUILD_MLIR" ON "ENABLE_MLIR_BACKEND" OFF)
cmake_dependent_option(NAUTILUS_DOWNLOAD_MLIR "USE_PRE_BUILD_MLIR" ON "ENABLE_MLIR_BACKEND;NOT USE_EXTERNAL_MLIR" OFF)
cmake_dependent_option(ENABLE_C_BACKEND "Enable the C compiler backend" ON "ENABLE_COMPILER" OFF)
cmake_dependent_option(ENABLE_BC_BACKEND "Enable the bytecode interpreter backend" ON "ENABLE_COMPILER" OFF)
cmake_dependent_option(ENABLE_ASMJIT_BACKEND "Enable the asmjit interpreter backend" OFF "ENABLE_COMPILER" OFF)
Expand All @@ -20,7 +22,7 @@ project(nautilus VERSION 0.1)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_FLAGS "-Wall -Wextra -pedantic -Werror=extra -Werror=all -fpermissive -fPIC -fno-omit-frame-pointer")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -Werror=extra -Werror=all -fpermissive -fPIC -fno-omit-frame-pointer")

if (ENABLE_TEST_COVERAGE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcoverage-mapping -fprofile-instr-generate")
Expand All @@ -45,29 +47,38 @@ include(cmake/macros.cmake)

set(THIRD_PARTY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party)

if (ENABLE_MLIR_BACKEND)
if (ENABLE_MLIR_BACKEND AND NOT USE_EXTERNAL_MLIR)
include(cmake/ImportMLIR.cmake)
endif ()

set(EXPORT_TARGETS)
if (ENABLE_TESTS)
set(CATCH_ENABLE_REPRODUCIBLE_BUILD OFF CACHE INTERNAL "Turn off tests")
add_subdirectory(${THIRD_PARTY_DIR}/Catch2)
list(APPEND EXPORT_TARGETS Catch2)
endif ()

if (ENABLE_LOGGING)
set(SPDLOG_COMPILED_LIB ON)
set(SPDLOG_BUILD_SHARED OFF)
add_subdirectory(${THIRD_PARTY_DIR}/spdlog)
if (USE_EXTERNAL_SPDLOG)
find_package(spdlog CONFIG REQUIRED)
else ()
set(SPDLOG_COMPILED_LIB ON)
set(SPDLOG_BUILD_SHARED OFF)
add_subdirectory(${THIRD_PARTY_DIR}/spdlog)
list(APPEND EXPORT_TARGETS spdlog)
endif ()
endif ()

if (ENABLE_STACKTRACE)
# Also requires one of: libbfd (gnu binutils), libdwarf, libdw (elfutils)
add_subdirectory(${THIRD_PARTY_DIR}/backward-cpp)
list(APPEND EXPORT_TARGETS backward_interface)
endif ()


if (ENABLE_BC_BACKEND)
add_subdirectory(${THIRD_PARTY_DIR}/dyncall)
list(APPEND EXPORT_TARGETS dyncall_s)
endif ()

if (ENABLE_ASMJIT_BACKEND)
Expand Down
4 changes: 0 additions & 4 deletions cmake/AddMLIR.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ if (MLIR_FOUND)
MLIRTargetLLVMIRExport
MLIRTransforms
)

# Include necessary mlir library in the deb package and install it in the lib folder
install(IMPORTED_RUNTIME_ARTIFACTS mlir_float16_utils mlir_runner_utils mlir_c_runner_utils mlir_async_runtime DESTINATION lib)

else ()
message(FATAL_ERROR "Cannot find mlir")
endif (MLIR_FOUND)
22 changes: 21 additions & 1 deletion nautilus/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ set_target_properties(nautilus PROPERTIES
)

if (ENABLE_LOGGING)
target_link_libraries(nautilus PRIVATE spdlog)
target_link_libraries(nautilus PRIVATE spdlog::spdlog)
endif ()

if (ENABLE_STACKTRACE)
Expand All @@ -46,5 +46,25 @@ if (ENABLE_TESTS)
add_subdirectory(test)
endif ()

# Handle CMake Install
include(GNUInstallDirs)
add_library(${PROJECT_NAME}::nautilus ALIAS nautilus)

install(
TARGETS nautilus ${EXPORT_TARGETS}
EXPORT ${PROJECT_NAME}-config
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
)

install(
EXPORT ${PROJECT_NAME}-config
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
NAMESPACE "${PROJECT_NAME}::"
)

install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/include/${PROJECT_NAME}/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})

# Install config.hpp
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/${PROJECT_NAME}/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})
2 changes: 1 addition & 1 deletion nautilus/include/nautilus/Executable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class Executable {
if (hasInvocableFunctionPtr()) {
return Invocable<R, Args...>(getInvocableFunctionPtr(member));
} else {
return Invocable<R, Args...>(std::move(getGenericInvocable(member)));
return Invocable<R, Args...>(getGenericInvocable(member));
}
}

Expand Down
3 changes: 2 additions & 1 deletion nautilus/src/nautilus/exceptions/Stacktrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ std::string printAndCollectCurrentStacktrace() {
} // namespace nautilus
#else
namespace nautilus {
void printCurrentStacktrace() {
std::string printAndCollectCurrentStacktrace() {
// nop if stacktrace is disabled.
return {};
}
} // namespace nautilus
#endif

0 comments on commit ce6b2df

Please sign in to comment.