Skip to content

Commit

Permalink
Set up installation directories also for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
robertodr committed Nov 22, 2016
1 parent 4d27e1f commit e51ec57
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 26 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ include(Fortran_C)
include(CXXFlags)
include(CFlags)
include(FortranFlags)
include(autocmake_custom_color_messages)
include(GNUdirs)
include(autocmake_ccache)
include(rpath)
Expand Down
1 change: 1 addition & 0 deletions cmake/autocmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ modules:
- 'custom/compilers/FortranFlags.cmake'
- plugins:
- source:
- '%(url_root)modules/custom_color_messages.cmake'
- 'custom/GNUdirs.cmake'
- '%(url_root)modules/ccache.cmake'
- 'custom/rpath.cmake'
Expand Down
11 changes: 10 additions & 1 deletion cmake/custom/GNUdirs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@
#
# autocmake.yml configuration::
#
# ?
# docopt:
# - "--bindir=<CMAKE_INSTALL_BINDIR> User executables [default: bin]."
# - "--libdir=<CMAKE_INSTALL_LIBDIR> Object code libraries [default: lib]."
# - "--includedir=<CMAKE_INSTALL_INCLUDEDIR> C header files [default: include]."
# - "--datadir=<CMAKE_INSTALL_DATADIR> Read-only architecture-independent data root [default: share]."
# define:
# - "'-DCMAKE_INSTALL_BINDIR={0}'.format(arguments['--bindir'])"
# - "'-DCMAKE_INSTALL_LIBDIR={0}'.format(arguments['--libdir'])"
# - "'-DCMAKE_INSTALL_INCLUDEDIR={0}'.format(arguments['--includedir'])"
# - "'-DCMAKE_INSTALL_DATADIR={0}'.format(arguments['--datadir'])"

if("${${CMAKE_INSTALL_LIBDIR}}" STREQUAL "" OR NOT DEFINED ${CMAKE_INSTALL_LIBDIR})
set(${CMAKE_INSTALL_LIBDIR} lib CACHE STRING "Directory to which libraries are installed" FORCE)
Expand Down
60 changes: 60 additions & 0 deletions cmake/downloaded/autocmake_custom_color_messages.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#.rst:
#
# Colorize CMake output.
# Code was found on StackOverflow: http://stackoverflow.com/a/19578320
#
# Usage within CMake code:
# message("This is normal")
# message("${Red}This is Red${ColourReset}")
# message("${Green}This is Green${ColourReset}")
# message("${Yellow}This is Yellow${ColourReset}")
# message("${Blue}This is Blue${ColourReset}")
# message("${Magenta}This is Magenta${ColourReset}")
# message("${Cyan}This is Cyan${ColourReset}")
# message("${White}This is White${ColourReset}")
# message("${BoldRed}This is BoldRed${ColourReset}")
# message("${BoldGreen}This is BoldGreen${ColourReset}")
# message("${BoldYellow}This is BoldYellow${ColourReset}")
# message("${BoldBlue}This is BoldBlue${ColourReset}")
# message("${BoldMagenta}This is BoldMagenta${ColourReset}")
# message("${BoldCyan}This is BoldCyan${ColourReset}")
# message("${BoldWhite}This is BoldWhite\n\n${ColourReset}")
#
# Has no effect on WIN32.

if(WIN32)
set(ColourReset "")
set(ColourBold "")
set(Red "")
set(Green "")
set(Yellow "")
set(Blue "")
set(Magenta "")
set(Cyan "")
set(White "")
set(BoldRed "")
set(BoldGreen "")
set(BoldYellow "")
set(BoldBlue "")
set(BoldMagenta "")
set(BoldCyan "")
set(BoldWhite "")
else()
string(ASCII 27 Esc)
set(ColourReset "${Esc}[m")
set(ColourBold "${Esc}[1m")
set(Red "${Esc}[31m")
set(Green "${Esc}[32m")
set(Yellow "${Esc}[33m")
set(Blue "${Esc}[34m")
set(Magenta "${Esc}[35m")
set(Cyan "${Esc}[36m")
set(White "${Esc}[37m")
set(BoldRed "${Esc}[1;31m")
set(BoldGreen "${Esc}[1;32m")
set(BoldYellow "${Esc}[1;33m")
set(BoldBlue "${Esc}[1;34m")
set(BoldMagenta "${Esc}[1;35m")
set(BoldCyan "${Esc}[1;36m")
set(BoldWhite "${Esc}[1;37m")
endif()
58 changes: 33 additions & 25 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,35 @@
./setup.py (-h | --help)
Options:
--fc=<FC> Fortran compiler [default: gfortran].
--extra-fc-flags=<EXTRA_FCFLAGS> Extra Fortran compiler flags [default: ''].
--cc=<CC> C compiler [default: gcc].
--extra-cc-flags=<EXTRA_CFLAGS> Extra C compiler flags [default: ''].
--cxx=<CXX> C++ compiler [default: g++].
--extra-cxx-flags=<EXTRA_CXXFLAGS> Extra C++ compiler flags [default: ''].
--ccache=<USE_CCACHE> Toggle use of ccache <ON/OFF> [default: ON].
--add-definitions=<STRING> Add preprocesor definitions [default: ''].
--coverage Enable code coverage [default: False].
--int64 Enable 64bit integers [default: False].
--omp Enable OpenMP parallelization [default: False].
--python=<PYTHON_INTERPRETER> The Python interpreter (development version) to use. [default: ''].
--boost-headers=<BOOST_INCLUDEDIR> Include directories for Boost [default: ''].
--boost-libraries=<BOOST_LIBRARYDIR> Library directories for Boost [default: ''].
--build-boost=<FORCE_CUSTOM_BOOST> Deactivate Boost detection and build on-the-fly <ON/OFF> [default: OFF].
--static Create only the static library [default: False].
--eigen=<EIGEN3_ROOT> Root directory for Eigen3 [default: ''].
--type=<TYPE> Set the CMake build type (debug, release, or relwithdeb) [default: release].
--generator=<STRING> Set the CMake build system generator [default: Unix Makefiles].
--show Show CMake command and exit.
--cmake-executable=<CMAKE_EXECUTABLE> Set the CMake executable [default: cmake].
--cmake-options=<STRING> Define options to CMake [default: ''].
--prefix=<PATH> Set the install path for make install.
<builddir> Build directory.
-h --help Show this screen.
--fc=<FC> Fortran compiler [default: gfortran].
--extra-fc-flags=<EXTRA_FCFLAGS> Extra Fortran compiler flags [default: ''].
--cc=<CC> C compiler [default: gcc].
--extra-cc-flags=<EXTRA_CFLAGS> Extra C compiler flags [default: ''].
--cxx=<CXX> C++ compiler [default: g++].
--extra-cxx-flags=<EXTRA_CXXFLAGS> Extra C++ compiler flags [default: ''].
--bindir=<CMAKE_INSTALL_BINDIR> User executables [default: bin].
--libdir=<CMAKE_INSTALL_LIBDIR> Object code libraries [default: lib].
--includedir=<CMAKE_INSTALL_INCLUDEDIR> C header files [default: include].
--datadir=<CMAKE_INSTALL_DATADIR> Read-only architecture-independent data root [default: share].
--ccache=<USE_CCACHE> Toggle use of ccache <ON/OFF> [default: ON].
--add-definitions=<STRING> Add preprocesor definitions [default: ''].
--coverage Enable code coverage [default: False].
--int64 Enable 64bit integers [default: False].
--omp Enable OpenMP parallelization [default: False].
--python=<PYTHON_INTERPRETER> The Python interpreter (development version) to use. [default: ''].
--boost-headers=<BOOST_INCLUDEDIR> Include directories for Boost [default: ''].
--boost-libraries=<BOOST_LIBRARYDIR> Library directories for Boost [default: ''].
--build-boost=<FORCE_CUSTOM_BOOST> Deactivate Boost detection and build on-the-fly <ON/OFF> [default: OFF].
--static Create only the static library [default: False].
--eigen=<EIGEN3_ROOT> Root directory for Eigen3 [default: ''].
--type=<TYPE> Set the CMake build type (debug, release, or relwithdeb) [default: release].
--generator=<STRING> Set the CMake build system generator [default: Unix Makefiles].
--show Show CMake command and exit.
--cmake-executable=<CMAKE_EXECUTABLE> Set the CMake executable [default: cmake].
--cmake-options=<STRING> Define options to CMake [default: ''].
--prefix=<PATH> Set the install path for make install.
<builddir> Build directory.
-h --help Show this screen.
"""


Expand All @@ -57,6 +61,10 @@ def gen_cmake_command(options, arguments):
command.append('-DEXTRA_FCFLAGS="{0}"'.format(arguments['--extra-fc-flags']))
command.append('-DEXTRA_CFLAGS="{0}"'.format(arguments['--extra-cc-flags']))
command.append('-DEXTRA_CXXFLAGS="{0}"'.format(arguments['--extra-cxx-flags']))
command.append('-DCMAKE_INSTALL_BINDIR={0}'.format(arguments['--bindir']))
command.append('-DCMAKE_INSTALL_LIBDIR={0}'.format(arguments['--libdir']))
command.append('-DCMAKE_INSTALL_INCLUDEDIR={0}'.format(arguments['--includedir']))
command.append('-DCMAKE_INSTALL_DATADIR={0}'.format(arguments['--datadir']))
command.append('-DUSE_CCACHE={0}'.format(arguments['--ccache']))
command.append('-DPREPROCESSOR_DEFINITIONS="{0}"'.format(arguments['--add-definitions']))
command.append('-DENABLE_CODE_COVERAGE={0}'.format(arguments['--coverage']))
Expand Down

0 comments on commit e51ec57

Please sign in to comment.