Skip to content

Commit

Permalink
#718: fix the way cmake options are passed to pressio-log
Browse files Browse the repository at this point in the history
  • Loading branch information
cwschilly committed Feb 19, 2025
1 parent e722669 commit 0f6a5ff
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 33 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci-baseline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ jobs:
-D CMAKE_INSTALL_PREFIX:PATH=${PRESSIO_INSTALL_DIR} \
-D CMAKE_VERBOSE_MAKEFILE:BOOL=ON \
${{ matrix.cmake_extra_args }} \
-D PRESSIO_ENABLE_DEBUG_PRINT=ON \
-D PRESSIO_ENABLE_TESTS:BOOL=ON \
-D PRESSIO_ENABLE_TPL_EIGEN:BOOL=ON \
-D EIGEN_INCLUDE_DIR=/eigen/eigen-${{ env.eigen_version }} \
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/ci-kokkos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ jobs:
-D PRESSIO_ENABLE_TPL_KOKKOS:BOOL=ON \
-D Kokkos_ROOT=/kokkos/install \
-D KokkosKernels_ROOT=/kokkos-kernels/install \
-D PRESSIO_ENABLE_DEBUG_PRINT=ON \
-D CMAKE_INSTALL_PREFIX:PATH=${PRESSIO_INSTALL_DIR} \
-D CMAKE_CXX_FLAGS='-Wall -Werror'
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/ci-trilinos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ jobs:
-D PRESSIO_ENABLE_TPL_KOKKOS:BOOL=ON \
-D PRESSIO_ENABLE_TPL_BLAS:BOOL=ON \
-D PRESSIO_ENABLE_TPL_LAPACK:BOOL=ON \
-D PRESSIO_ENABLE_DEBUG_PRINT=ON \
-D EIGEN_INCLUDE_DIR=/eigen/eigen-${{ env.eigen_version }} \
-D Trilinos_DIR=${{ env.trilinos_dir }}/lib/cmake/Trilinos \
-D CMAKE_INSTALL_PREFIX:PATH=${PRESSIO_INSTALL_DIR} \
Expand Down
21 changes: 17 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,33 @@ else()
set(PRESSIO_OPS_INCLUDE_DIR ${pressio-ops_SOURCE_DIR}/include)
endif()

# pull in pressio-log and read macros
# logging
#=====================================================================
# pressio-log options must be configured here and stored in the cache
set(PRESSIO_ENABLE_COLORIZED_OUTPUT ON CACHE BOOL "Enable or disable colorized logging." )
set(PRESSIO_SILENCE_WARNINGS OFF CACHE BOOL "Enable or disable warnings" )
set(PRESSIO_ENABLE_EXTERNAL_FMT OFF CACHE BOOL "Allow using an externally provided fmt library")
set(fmt_INCLUDE_DIR "" CACHE STRING "Include directory of fmt library." )
set(fmt_ROOT "" CACHE STRING "Root directory of fmt library." )
set(fmt_DIR "" CACHE STRING "Root directory of fmt library." )

option(PRESSIO_ENABLE_LOGGING "Enable logging via pressio-log" ON)
if (PRESSIO_ENABLE_LOGGING)
add_compile_definitions(PRESSIO_ENABLE_LOGGING=1)
else()
add_compile_definitions(PRESSIO_ENABLE_LOGGING=0)
endif()

# get pressio-log (either find it or fetch it)
message(STATUS "PRESSIO_ENABLE_LOGGING = ${PRESSIO_ENABLE_LOGGING}")
if (PRESSIO_ENABLE_LOGGING)
if(PRESSIO_LOG_INCLUDE_DIR)
message("${Green}-- Using ${PRESSIO_LOG_INCLUDE_DIR}")
if(PRESSIO_LOG_DIR)
message("${Green}-- Using ${PRESSIO_LOG_DIR}")
add_subdirectory(${PRESSIO_LOG_DIR} ${CMAKE_BINARY_DIR}/pressio-log)
set(PRESSIO_LOG_INCLUDE_DIR ${PRESSIO_LOG_DIR}/include)
else()
include(FetchContent)
message("${Green}-- PRESSIO_LOG_INCLUDE_DIR is not defined, so fetching pressio-log...")
message("${Green}-- PRESSIO_LOG_DIR is not defined, so fetching pressio-log...")
FetchContent_Declare(
pressio-log
GIT_REPOSITORY https://github.com/Pressio/pressio-log.git
Expand Down Expand Up @@ -97,6 +108,8 @@ install(
if(PRESSIO_ENABLE_TESTS)
add_library(pressio INTERFACE)

target_link_libraries(pressio INTERFACE pressio-log)

target_include_directories(
pressio INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include;${PRESSIO_OPS_INCLUDE_DIR}>"
Expand Down
4 changes: 2 additions & 2 deletions docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ or you can pick a `release version <https://github.com/Pressio/pressio/releases>
3. Use cmake to configure by passing to the comand line the target list of cmake variables to define.

For example, suppose we want to enable support for Trilinos and the debug prints. We would do:
For example, suppose we want to enable support for Trilinos and the loger. We would do:

.. code-block:: bash
Expand All @@ -98,7 +98,7 @@ For example, suppose we want to enable support for Trilinos and the debug prints
cmake -D CMAKE_INSTALL_PREFIX=../install \
-D PRESSIO_ENABLE_TPL_TRILINOS=ON \
-D PRESSIO_ENABLE_DEBUG_PRINT=ON \
-D PRESSIO_ENABLE_LOGGING=ON \
${PRESSIO_SRC}
make install # nothing is built, just headers copied to installation
Expand Down
4 changes: 0 additions & 4 deletions docs/source/keywords.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,6 @@ Other Options
- Description
- Default

* - ``PRESSIO_ENABLE_DEBUG_PRINT``
- to enable debugging print statements
- ``OFF``

* - ``PRESSIO_ENABLE_CXX20``
- enables C++20 standard
- ``OFF``; turned on if ``CMAKE_CXX_STANDARD`` is set to 20
20 changes: 0 additions & 20 deletions tests/cmake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,6 @@ if(CMAKE_CXX_STANDARD EQUAL 20)
add_definitions(-DPRESSIO_ENABLE_CXX20)
endif()

option(PRESSIO_ENABLE_DEBUG_PRINT "Enable debug printing" OFF)
if (PRESSIO_ENABLE_DEBUG_PRINT)
add_definitions(-DPRESSIO_ENABLE_DEBUG_PRINT)
endif()

# LOGGING MACROS
option(PRESSIO_SILENCE_WARNINGS "Enable or disable warnings" OFF)
if (PRESSIO_SILENCE_WARNINGS)
add_compile_definitions(PRESSIO_SILENCE_WARNINGS=1)
else ()
add_compile_definitions(PRESSIO_SILENCE_WARNINGS=0)
endif()

option(PRESSIO_ENABLE_COLORIZED_OUTPUT "Enable or disable colorized logging" OFF)
if (PRESSIO_ENABLE_COLORIZED_OUTPUT)
add_compile_definitions(PRESSIO_ENABLE_COLORIZED_OUTPUT=1)
else ()
add_compile_definitions(PRESSIO_ENABLE_COLORIZED_OUTPUT=0)
endif()

# TPLs
option(PRESSIO_ENABLE_TPL_EIGEN "Enable Eigen TPL" ON)
option(PRESSIO_ENABLE_TPL_TRILINOS "Enable Trilinos TPL" OFF)
Expand Down

0 comments on commit 0f6a5ff

Please sign in to comment.