Skip to content

Commit

Permalink
Make app4triqs not depend on triqs
Browse files Browse the repository at this point in the history
Co-authored-by: Dylan Simon <dylan@dylex.net>
Co-authored-by: Thomas Hahn <thomas.hahn01@gmail.com>
  • Loading branch information
3 people committed Sep 20, 2024
1 parent 4ea86b4 commit d1c70c4
Show file tree
Hide file tree
Showing 46 changed files with 818 additions and 858 deletions.
23 changes: 4 additions & 19 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: build

on:
push:
branches: [ unstable, '[0-9]+.[0-9]+.x' ]
branches: [ notriqs, '[0-9]+.[0-9]+.x' ]
pull_request:
branches: [ unstable, '[0-9]+.[0-9]+.x' ]
branches: [ notriqs, '[0-9]+.[0-9]+.x' ]
workflow_call:
workflow_dispatch:

Expand Down Expand Up @@ -56,7 +56,6 @@ jobs:
gfortran
hdf5-tools
libblas-dev
libboost-dev
libclang-15-dev
libc++-15-dev
libc++abi-15-dev
Expand All @@ -73,7 +72,6 @@ jobs:
python3-clang-15
python3-dev
python3-mako
python3-matplotlib
python3-mpi4py
python3-numpy
python3-pip
Expand All @@ -84,7 +82,7 @@ jobs:
- name: Install homebrew dependencies
if: matrix.os == 'macos-12'
run: |
brew install ccache gcc@12 llvm boost fftw hdf5 open-mpi openblas
brew install ccache gcc@12 llvm hdf5 open-mpi openblas
mkdir $HOME/.venv
python3 -m venv $HOME/.venv/my_python
source $HOME/.venv/my_python/bin/activate
Expand All @@ -99,33 +97,20 @@ jobs:
echo "PATH=/usr/local/opt/llvm/bin:$PATH" >> $GITHUB_ENV
echo "CXXFLAGS=-stdlib=libc++" >> $GITHUB_ENV
- name: Build & Install TRIQS
env:
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
run: |
git clone https://github.com/TRIQS/triqs --branch ${{ github.ref_name }}
mkdir triqs/build && cd triqs/build
cmake .. -DBuild_Tests=OFF -DCMAKE_INSTALL_PREFIX=$HOME/install
make -j1 install VERBOSE=1
cd ../
- name: Build app4triqs
env:
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
LIBRARY_PATH: /usr/local/opt/llvm/lib
run: |
source $HOME/install/share/triqs/triqsvars.sh
mkdir build && cd build && cmake ..
mkdir build && cd build && cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/install
make -j2 || make -j1 VERBOSE=1
- name: Test app4triqs
env:
DYLD_FALLBACK_LIBRARY_PATH: /usr/local/opt/llvm/lib
OPENBLAS_NUM_THREADS: "1"
run: |
source $HOME/install/share/triqs/triqsvars.sh
cd build
ctest -j2 --output-on-failure
Expand Down
51 changes: 30 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,22 @@ cmake_policy(VERSION ${CMAKE_VERSION})

# ############
# Define Project
project(app4triqs VERSION 3.3.0 LANGUAGES CXX)
project(app4triqs VERSION 1.3.0 LANGUAGES CXX)
get_directory_property(IS_SUBPROJECT PARENT_DIRECTORY)

# ############
# Load TRIQS and CPP2PY
find_package(TRIQS 3.3 REQUIRED)

# Get the git hash & print status
triqs_get_git_hash_of_source_dir(PROJECT_GIT_HASH)
message(STATUS "-------- app4triqs version and git hash detection -------------")
find_package(Git)
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE PROJECT_GIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
message(STATUS "${PROJECT_NAME} version : ${PROJECT_VERSION}")
message(STATUS "${PROJECT_NAME} Git hash: ${PROJECT_GIT_HASH}")

# Enforce Consistent Versioning
if(NOT ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} VERSION_EQUAL ${TRIQS_VERSION_MAJOR}.${TRIQS_VERSION_MINOR})
message(FATAL_ERROR "The ${PROJECT_NAME} version ${PROJECT_VERSION} is not compatible with TRIQS version ${TRIQS_VERSION}.")
endif()

# Default Install directory to TRIQS_ROOT if not given or when provided as relative path.
# Assert that install directory is provided and is absolute path.
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR (NOT IS_ABSOLUTE ${CMAKE_INSTALL_PREFIX}))
message(STATUS "No install prefix given (or invalid). Defaulting to TRIQS_ROOT")
set(CMAKE_INSTALL_PREFIX ${TRIQS_ROOT} CACHE PATH "default install path" FORCE)
set(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT FALSE)
message(FATAL_ERROR "No install prefix given (or invalid)")
endif()
if(NOT IS_SUBPROJECT)
message(STATUS "-------- CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX} --------")
Expand All @@ -68,9 +62,6 @@ endif()

# Python Support
option(PythonSupport "Build with Python support" ON)
if(PythonSupport AND NOT TRIQS_WITH_PYTHON_SUPPORT)
message(FATAL_ERROR "TRIQS was installed without Python support. Cannot build the Python Interface. Disable the build with -DPythonSupport=OFF")
endif()

# Documentation
option(Build_Documentation "Build documentation" OFF)
Expand Down Expand Up @@ -122,6 +113,25 @@ target_compile_options(${PROJECT_NAME}_warnings
$<$<CXX_COMPILER_ID:IntelLLVM>:-Wno-tautological-constant-compare>
)

# ---------------------------------
# Resolve Clang Linktime Problems
# CMake will adjust any linker flags from '-L path_to/mylib.so' to -lmylib
# if the proper mylib.so is automatically found by the linker, i.e.
# the directory comes first in LIBRARY_PATH.
# The clang linker however ignores LIBRARY_PATH.
# We thus explicitly add the content of LIBRARY_PATH to the LDFLAGS
# FIXME For future cmake versions we should populate the
# INTERFACE_LINK_DIRECTORIES of the triqs target
# ---------------------------------
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND DEFINED ENV{LIBRARY_PATH})
string(REPLACE ":" ";" LINK_DIRS $ENV{LIBRARY_PATH})
foreach(dir ${LINK_DIRS})
string(APPEND CMAKE_SHARED_LINKER_FLAGS " -L${dir}")
string(APPEND CMAKE_MODULE_LINKER_FLAGS " -L${dir}")
string(APPEND CMAKE_EXE_LINKER_FLAGS " -L${dir}")
endforeach()
endif()

# Provide GNU Installation directories
include(GNUInstallDirs)

Expand Down Expand Up @@ -167,8 +177,7 @@ if(BUILD_DEBIAN_PACKAGE AND NOT IS_SUBPROJECT)
set(CPACK_GENERATOR "DEB")
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_PACKAGE_CONTACT "https://github.com/TRIQS/${PROJECT_NAME}")
execute_process(COMMAND dpkg --print-architecture OUTPUT_VARIABLE CMAKE_DEBIAN_PACKAGE_ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE)
set(CPACK_DEBIAN_PACKAGE_DEPENDS "triqs (>= 3.3)")
execute_process(COMMAND dpkg --print-architecture OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE)
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS ON)
include(CPack)
Expand Down
Loading

0 comments on commit d1c70c4

Please sign in to comment.