From 9851a2ced5c456bac5c15e06258c56b987c348ba Mon Sep 17 00:00:00 2001 From: Victor Azizi Date: Wed, 6 Apr 2022 10:25:55 +0200 Subject: [PATCH] CMAKE use CONDA_PREFIX as installation path when defined --- CMakeLists.txt | 8 +++++++- docs/installation.rst | 5 ++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 35a44ae..e0d3629 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,9 +9,15 @@ set(CMAKE_Fortran_COMPILER ${Fortran_COMPILER}) project(QUICKLB LANGUAGES Fortran) +if (DEFINED ENV{CONDA_PREFIX}) + set(CMAKE_INSTALL_PREFIX $ENV{CONDA_PREFIX} CACHE PATH "..." FORCE) +endif() +message(STATUS "Install prefix: ${CMAKE_INSTALL_PREFIX}" ) + + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -Wall -Wextra \ -Wno-compare-reals -ffixed-form -fimplicit-none \ - -ffixed-line-length-none") # Shared Flags + -ffixed-line-length-none -march=native -mtune=native") # Shared Flags if (CMAKE_Fortran_COMPILER_ID MATCHES "Intel") set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fpp") #Preprocessor else() diff --git a/docs/installation.rst b/docs/installation.rst index e558fb4..d533462 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -28,16 +28,19 @@ For python functionality: - matplotlib **>= 3.5.1** - scipy **>= 1.8** -The library can be created through cmake directly: +The library can be created through cmake directly, the CMakeFile honors the CONDA_PREFIX if present, and tries to install there instead of the default install location: .. code:: bash $ mkdir build $ cd build $ cmake ../ -DFortran_COMPILER=mpif90 -DCMAKE_BUILD_TYPE={RELEASE,DEBUG} -DPYTHON_INTERFACE={off,on} + $ make + $ make install Or it can be created throught the python setuptools: .. code:: bash $ python setup.py install +