Commit c9f3def7 authored by jclamber's avatar jclamber

more fixes on cmake stuff

git-svn-id: http://svn.oamp.fr/repos/unsio/trunk@112 ce2cc22f-6084-46ce-a062-084b172ee5dc
parent 05ea1ca4
# ============================================================================
# Copyright Jean-Charles LAMBERT - 2009-2012
# e-mail: Jean-Charles.Lambert@oamp.fr
# address: Dynamique des galaxies
# Centre de donneeS Astrophysique de Marseille (CeSAM)
# Laboratoire d'Astrophysique de Marseille
# Pole de l'Etoile, site de Chateau-Gombert
# 38, rue Frederic Joliot-Curie
# 13388 Marseille cedex 13 France
# CNRS U.M.R 6110
# ============================================================================
# CMakeListst.txt file for nemo library
# ============================================================================
cmake_minimum_required(VERSION 2.6)
# project name
project (nemo)
# set CMAKE Module PATH (NEMO)
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_BINARY_DIR})
MESSAGE( STATUS "CMAKE_MODULE_PATH=" ${CMAKE_MODULE_PATH} )
# contains the full path to the top level directory of your build tree
MESSAGE( STATUS "PROJECT_BINARY_DIR: " ${PROJECT_BINARY_DIR} )
MESSAGE( STATUS "PROJECT_SOURCE_DIR: " ${PROJECT_SOURCE_DIR} )
MESSAGE( STATUS "CMAKE_BUILD_TYPE =" ${CMAKE_BUILD_TYPE} )
MESSAGE( STATUS "CMAKE_CXX_FLAGS =" ${CMAKE_CXX_FLAGS} )
MESSAGE( STATUS "LIBRARY TYPE =" ${LIBTYPE} )
MESSAGE( STATUS "nemolight OPT =" ${OPT} )
# Lib : libnemo.so
# Find all the sources for the utils LIB
FILE(GLOB LIBUTILS ../src/*.c )
# create the library "libnemo.so"
add_library (nemo ${LIBTYPE} ${LIBUTILS})
# Lib : libnemomaing77.so
# Find all the sources for old fortran compiler
FILE(GLOB LIBUTILS ../src/fortran_old_gcc/*.c )
# create the library "libnemomaing77.so"
add_library (nemomaing77 ${LIBTYPE} ${LIBUTILS})
if(OSX)
set_target_properties(MNESSutils PROPERTIES LINK_FLAGS "-undefined suppress -flat_namespace")
endif(OSX)
# Destination path for the lib
SET(LIBRARY_OUTPUT_PATH ../lib)
# compilation options
add_definitions(-Wall ${OPT} -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE)
# SET NEMOPATH
SET(NEMOLIB ${PROJECT_SOURCE_DIR}/../lib)
SET(NEMOINC ${PROJECT_SOURCE_DIR}/../src/inc)
# Make sure the compiler can find include files from our Hello library.
include_directories (../src/inc )
#
# install bin targets
#
......@@ -18,7 +18,6 @@ cmake_minimum_required(VERSION 2.6)
project (UNSIO)
SET(CMAKE_VERBOSE_MAKEFILE OFF)
# extra path for NEMO
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
......@@ -26,11 +25,6 @@ SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
# load setup flags
include(SetupFlags)
SET(OSX FALSE)
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
SET(OSX TRUE)
endif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# contains the full path to the top level directory of your build tree
MESSAGE( STATUS "PROJECT_BINARY_DIR: " ${PROJECT_BINARY_DIR} )
......@@ -43,6 +37,8 @@ MESSAGE( STATUS "CMAKE_CXX_FLAGS =" ${CMAKE_CXX_FLAGS} )
MESSAGE( STATUS "LIBRARY TYPE =" ${LIBTYPE} )
MESSAGE( STATUS "core OPT =" ${OPT} )
MESSAGE( STATUS "OSX detected =" ${OSX} )
MESSAGE( STATUS "BUILD_TYPE =" ${RELEASE} )
FIND_PACKAGE(NEMO)
FIND_PACKAGE(SQLITE3)
......@@ -156,11 +152,7 @@ ENDIF ()#NOT CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
MESSAGE( STATUS "--------> CMAKE_INSTALL_PREFIX =" ${CMAKE_INSTALL_PREFIX})
# unsio lib
FILE(GLOB unsio_files ${UNSIO_BINARY_DIR}/lib/libunsio.*)
FOREACH(file_lib ${unsio_files})
MESSAGE( STATUS " files: " ${file_lib})
INSTALL(FILES ${file_lib} DESTINATION lib)
ENDFOREACH()
INSTALL(FILES ${UNSIO_BINARY_DIR}/lib/libunsio.${LIBEXT} DESTINATION lib)
# UNS specific includes
......@@ -173,11 +165,10 @@ INSTALL(FILES ${UNSIO_BINARY_DIR}/../src/userselection.h DESTINATION inc/uns)
# NEMO specific includes
IF (NOT NEMO_INSTALLED)
# install nemolighlib
FILE(GLOB nlight_files ${NEMOLIGHT}/lib/lib*)
FOREACH(file_lib ${nlight_files})
INSTALL(FILES ${file_lib} DESTINATION lib)
ENDFOREACH()
# install nemo lib
INSTALL(FILES ${NEMOLIGHT}/lib/libnemo.${LIBEXT} DESTINATION lib)
INSTALL(FILES ${NEMOLIGHT}/lib/libnemomaing77.${LIBEXT} DESTINATION lib)
# Find all NEMOLIGHT header files
FILE(GLOB nlight_files ${NEMOLIGHT}/src/*.h ${NEMOLIGHT}/src/inc/*.h)
......@@ -196,4 +187,4 @@ INSTALL(FILES ${UNSIO_BINARY_DIR}/../man/man3/unsiof.3 DESTINATION man/man3)
# some binaries
#set (CMAKE_INSTALL_PREFIX $ENV{NEMOBIN})
#INSTALL(PROGRAMS ${UNSIO_BINARY_DIR}/../bin/unscpp DESTINATION bin)
INSTALL(PROGRAMS ${UNSIO_BINARY_DIR}/bin/uns_info DESTINATION bin)
CONFIGURATION
=============
UNSIO installation
I) REQUIREMENTS
===============
Unsio should compile fine on Linux and MacOSX. You just need a recent
gcc/g++ compiler and cmake tools (version 2.6). Cmake tools can be
installed directly from your distribution or downloaded from here :
http://www.cmake.org/cmake/resources/software.html
II) CONFIGURATION
=================
To configure UNSIO, type
mkdir build
cd build
cmake ..
mkdir build
cd build
cmake ..
in the directory that contains this INSTALL file. You can add several options
to this command. The most important ones are
You can add several options to command "cmake". The most important ones are
-DCMAKE_INSTALL_PREFIX=<dir> installation directory [${HOME}/local/unsio]
-DCMAKE_INSTALL_PREFIX=<dir> installation directory [${NEMO}]
-DCMAKE_BUILD_TYPE=<Debug|Release> build type [Debug]
-DBUILD_SHARED_LIBS=<TRUE|FALSE> shared or static libraries [TRUE]
-DCMAKE_C_COMPILER=<program> C compiler [gcc]
-DCMAKE_CXX_COMPILER=<program> C++ compiler [g++]
Here is different scenarios :
1) default configuration (no options added)
-------------------------------------------
mkdir build-debug
cd build-debug
cmake ..
Will configure unsio in "debug" mode, with shared library and
installation path will be
a) in ${NEMO} if NEMO package is installed and loaded
b) if not NEMO installed nor loaded, it will install to ${HOME}/local/unsio
2) you specify your own installation path
------------------------------------------
mkdir build-test
cd nuild_test
cmake .. -DCMAKE_INSTALL_PREFIX="/mypath/toinstall"
Will configure unsio in "debug" mode, with shared library and
installation path to "/mypath/toinstall"
3) you want compile in release mode (with optimizations enabled)
----------------------------------------------------------------
mkdir build-release
cd build-release
cmake .. -DCMAKE_BUILD_TYPE=Release
Will configure unsio in "release" mode with shared library and
installation path will be
a) in ${NEMO} if NEMO package is installed and loaded
b) if not NEMO installed nor loaded, it will install to ${HOME}/local/unsio
4) so forth and so on.....
Note that CMake maintains a cache name "CMakeCache.txt". If you change options
......@@ -22,12 +66,12 @@ Note that CMake maintains a cache name "CMakeCache.txt". If you change options
problems.
BUILDING
========
III) BUILDING
==============
To build the UNSIO libraries, type
make (or nmake in a Windows command prompt)
make
If you want, you can install the UNSIO header and libraries. To do so, type
......
......@@ -33,20 +33,43 @@ else ()
typed_cache_set (STRING "Optimizer" OPT "-O3")
endif ()
# just for testing
option(RELEASE "RELEASE " ON) # SHARED lib default
if ( NOT RELEASE ) # Debug TRUE
typed_cache_set ( BOOL "RELEASE Version" RELEASE FALSE )
else () # else FALSE
typed_cache_set ( BOOL "RELEASE Version" RELEASE TRUE )
endif()
# detect MacOS
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
typed_cache_set ( BOOL "OSX detection" OSX TRUE )
else()
typed_cache_set ( BOOL "OSX detection" OSX FALSE )
endif()
# SHARED lib ?
option(BUILD_SHARED_LIBS "Shared lib " ON) # SHARED lib default
if ( NOT BUILD_SHARED_LIBS ) # Debug TRUE
typed_cache_set ( BOOL "Build SHARED" BUILD_SHARED_LIBS FALSE )
else () # else FALSE
typed_cache_set ( BOOL "Build SHARED" BUILD_SHARED_LIBS TRUE)
endif()
# set library type , SHARED or STATIC
# set library type , SHARED or STATIC + LIB extension
if ( BUILD_SHARED_LIBS )
typed_cache_set ( STRING "LIB TYPE" LIBTYPE SHARED )
if (OSX)
typed_cache_set ( STRING "LIB TYPE" LIBEXT "dylib" )
else()
typed_cache_set ( STRING "LIB TYPE" LIBEXT "so" )
endif()
else ()
typed_cache_set ( STRING "LIB TYPE" LIBTYPE STATIC )
typed_cache_set ( STRING "LIB TYPE" LIBEXT "a" )
endif()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment