Skip to content

Commit

Permalink
Implement m-variables
Browse files Browse the repository at this point in the history
The m-variables provide the same functionality as their
template metaprogramming-based version by using macros. This
new implementation ensures considerably faster compile times.
  • Loading branch information
fdevinc committed Jun 28, 2024
1 parent 07d0d97 commit 9383fb0
Show file tree
Hide file tree
Showing 8 changed files with 842 additions and 21 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ endif()
list(APPEND UNGAR_INCLUDE_DIRECTORIES
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
list(APPEND UNGAR_LINK_LIBRARIES Eigen3::Eigen hana)
list(APPEND UNGAR_LINK_LIBRARIES Eigen3::Eigen hana Boost::preprocessor)

# Optional modules.
if(UNGAR_ENABLE_LOGGING)
Expand Down
34 changes: 34 additions & 0 deletions external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ elseif(NOT UNGAR_USE_SYSTEM_LIBRARIES)
set(HANA_ROOT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/hana/install)
endif()

# Preprocessor.
if(DEFINED Preprocessor_ROOT)
set(PREPROCESSOR_ROOT_DIRECTORY ${Preprocessor_ROOT})
elseif(NOT UNGAR_USE_SYSTEM_LIBRARIES)
set(USE_BUNDLED_PREPROCESSOR ON)
set(BUNDLED_PREPROCESSOR_FILENAME
${CMAKE_CURRENT_LIST_DIR}/config/preprocessor/preprocessor-1.84.0-ungar.zip
)
set(PREPROCESSOR_ROOT_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}/preprocessor/install)
endif()

# GoogleTest.
if(DEFINED GTest_ROOT)
set(GTEST_ROOT_DIRECTORY ${GTest_ROOT})
Expand Down Expand Up @@ -161,6 +173,28 @@ else()
message(STATUS "Hana found.")
endif()

# ##############################################################################
# Add Preprocessor.
# ##############################################################################
message(STATUS "--------------------------------------------------")
if(USE_BUNDLED_PREPROCESSOR)
message(STATUS "Using bundled Preprocessor...")
download_external_project(config/preprocessor/CMakeLists.txt.in preprocessor)
find_package(
Preprocessor REQUIRED PATHS
${PREPROCESSOR_ROOT_DIRECTORY}/lib/cmake/preprocessor NO_DEFAULT_PATH)
else()
message(STATUS "Using system-wide Preprocessor...")
find_package(Preprocessor REQUIRED)
endif()
set_target_properties(Boost::preprocessor PROPERTIES IMPORTED_GLOBAL TRUE)

if(DEFINED PREPROCESSOR_ROOT_DIRECTORY)
message(STATUS "Preprocessor found at '${PREPROCESSOR_ROOT_DIRECTORY}'.")
else()
message(STATUS "Preprocessor found.")
endif()

# ===========================================================================
# 2) TESTING
if(UNGAR_BUILD_TESTS)
Expand Down
24 changes: 24 additions & 0 deletions external/config/preprocessor/CMakeLists.txt.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
cmake_minimum_required(VERSION 3.20)

project(ExternalPreprocessor NONE)

include(ExternalProject)

if(NOT @Preprocessor_CMAKE_FLAGS@ STREQUAL "")
message(
STATUS "Preprocessor additional CMake flags: @Preprocessor_CMAKE_FLAGS@")
endif()

ExternalProject_Add(
preprocessor-1.84.0-ungar
URL @BUNDLED_PREPROCESSOR_FILENAME@
URL_HASH
SHA256=6c5a4bf474c1ee5355d426a0a890d96186361eb66b73666bb09dc4062270435f
CMAKE_CACHE_ARGS
-DCMAKE_CXX_STANDARD:STRING=20
-DCMAKE_INSTALL_PREFIX:STRING=@CMAKE_CURRENT_BINARY_DIR@/preprocessor/install
-DBUILD_TESTING:BOOL=OFF
-DBOOST_PREPROCESSOR_INSTALL:BOOL=ON
@Preprocessor_CMAKE_FLAGS@
UPDATE_DISCONNECTED 1
DOWNLOAD_EXTRACT_TIMESTAMP 1)
Binary file not shown.
362 changes: 362 additions & 0 deletions include/ungar/mvariable.hpp

Large diffs are not rendered by default.

Loading

0 comments on commit 9383fb0

Please sign in to comment.