Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CMake Build System File Generator Support #94

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.vscode/
.DS_Store
.DS_Store
build/
36 changes: 36 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
cmake_minimum_required(VERSION 3.12)

project("Boost.uBLAS.Test"
DESCRIPTION "Boost.uBLAS is part of the Boost C++ Libraries. It is directed towards scientific computing on the level of basic linear and multilinear algebra operations with tensors, matrices and vectors."
HOMEPAGE_URL "https://github.com/boostorg/ublas")


option(BUILD_EXAMPLES "Build the examples directory" ON)
option(BUILD_TENSOR_TEST "Build Tensor Unit Tests" ON)
option(BUILD_BENCHMARKS "Build Benchmarks Directory" ON)

set(BOOST_HEADERS_DIR "" CACHE PATH "Directory of include files generated by b2 headers")

if(BOOST_HEADERS_DIR STREQUAL "")
message(STATUS "No Boost Headers specified, Looking for System installed headers")
find_package(Boost COMPONENTS unit_test_framework REQUIRED)
set(BOOST_HEADERS_DIR ${Boost_INCLUDE_DIRS} CACHE PATH "System Boost Installation include Directory" FORCE)
message(STATUS "Using Boost headers at : ${BOOST_HEADERS_DIR}. Use -DBOOST_HEADER_DIR=<path> to overwrite")
endif()

set(UBLAS_HEADER_DIR ${CMAKE_SOURCE_DIR}/include)

if(BUILD_EXAMPLES)
message(STATUS "Examples will be build. You will have to run them manually")
add_subdirectory(examples/tensor)
endif()

if(BUILD_TENSOR_TEST)
message(STATUS "Tensor Unit Tests will be build. Use ctest to run the tests")
add_subdirectory(test/tensor)
endif()

if(BUILD_BENCHMARKS)
message(STATUS "Benchmarks will be build. You will have to run them manually")
add_subdirectory(benchmarks)
endif()
36 changes: 36 additions & 0 deletions benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
cmake_minimum_required(VERSION 3.12)

project("Boost.uBLAS.Benchmark"
DESCRIPTION "Boost.uBLAS.Benchmark is part of the Boost C++ Libraries. It is directed towards benchmarking various operations within Boost.uBLAS"
HOMEPAGE_URL "https://github.com/boostorg/ublas")

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

include_directories(SYSTEM ${BOOST_HEADERS_DIR})
include_directories(${UBLAS_HEADER_DIR})

# If you decide to use any other Boost library that requires linkage
# you should add them to the list of components in the below line.
# To link call `link_libraries(<name>)`. This library will be linked to all targets.
# To link to specific target, use `target_link_libraries(<name_of_target> <lib>)` after
# you have created the target with `add_executable(<name_of_target> <sources>)`

find_package(Boost COMPONENTS program_options REQUIRED)
link_libraries(${Boost_PROGRAM_OPTIONS_LIBRARY})

# Add new benchmarks here.

add_executable(add add.cpp)
add_executable(mm_prod mm_prod.cpp)
add_executable(mv_prod mv_prod.cpp)
add_executable(inner_prod inner_prod.cpp)
add_executable(outer_prod outer_prod.cpp)

# Add a reference to benchamark here.
add_executable(add_ref reference/add.cpp)
add_executable(mm_prod_ref reference/mm_prod.cpp)
add_executable(mv_prod_ref reference/mv_prod.cpp)
add_executable(inner_prod_ref reference/inner_prod.cpp)
add_executable(outer_prod_ref reference/outer_prod.cpp)

24 changes: 24 additions & 0 deletions examples/tensor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
cmake_minimum_required(VERSION 3.12)

project("Boost.uBLAS.Examples"
DESCRIPTION "Boost.uBLAS.Examples is part of the Boost C++ Libraries. It is directed towards showing different use cases and examples to get started with various operations within Boost.uBLAS"
HOMEPAGE_URL "https://github.com/boostorg/ublas")

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

include_directories(SYSTEM ${BOOST_HEADERS_DIR})
include_directories(${UBLAS_HEADER_DIR})

# Add a new example here. Use spaces and respect my beautiful alignment.

add_executable(construction_access construction_access.cpp)
add_executable(simple_expressions simple_expressions.cpp)
add_executable(dynamic_prod_expressions dynamic_prod_expressions.cpp)
add_executable(fixed_rank_prod_expressions fixed_rank_prod_expressions.cpp)
add_executable(static_prod_expressions static_prod_expressions.cpp)
add_executable(fixed_rank_tensor fixed_rank_tensor.cpp)
add_executable(static_tensor static_tensor.cpp)
add_executable(einstein_notation einstein_notation.cpp)
add_executable(tensor_construction tensor_construction.cpp)

62 changes: 62 additions & 0 deletions test/tensor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
cmake_minimum_required(VERSION 3.12)

project("Boost.uBLAS.TensorTest"
DESCRIPTION "Boost.uBLAS.TensorTest is part of the Boost C++ Libraries. It is directed towards testing Boost.uBLAS.Tensor various operations within Boost.uBLAS"
HOMEPAGE_URL "https://github.com/boostorg/ublas")

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

include_directories(SYSTEM ${BOOST_HEADERS_DIR})
include_directories(${UBLAS_HEADER_DIR})

add_executable(
test_tensor
test_tensor.cpp
test_strides.cpp
test_expression.cpp
test_operators_comparison.cpp
test_operators_arithmetic.cpp
test_multiplication.cpp
test_multi_index_utility.cpp
test_multi_index.cpp
test_extents.cpp
test_expression_evaluation.cpp
test_einstein_notation.cpp
test_algorithms.cpp
test_tensor_matrix_vector.cpp
test_functions.cpp)

add_executable(
test_static_tensor
test_static_tensor.cpp
test_static_extents.cpp
test_static_strides.cpp
test_static_operators_arithmetic.cpp
test_static_operators_comparison.cpp
test_static_expression_evaluation.cpp
test_static_tensor_matrix_vector.cpp
test_static_functions.cpp)

add_executable(
test_fixed_rank_tensor
test_fixed_rank_tensor.cpp
test_fixed_rank_extents.cpp
test_fixed_rank_strides.cpp
test_fixed_rank_operators_arithmetic.cpp
test_fixed_rank_operators_comparison.cpp
test_fixed_rank_expression_evaluation.cpp
test_fixed_rank_tensor_matrix_vector.cpp
test_fixed_rank_functions.cpp)

find_package(Boost COMPONENTS unit_test_framework REQUIRED)

target_link_libraries(test_tensor ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
target_link_libraries(test_static_tensor ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
target_link_libraries(test_fixed_rank_tensor ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})

enable_testing()

add_test(NAME TensorTests COMMAND test_tensor)
add_test(NAME TensorFixedRank COMMAND test_fixed_rank_tensor)
add_test(NAME TensorStatic COMMAND test_static_tensor)