Source

PetIGA / CMakeLists.txt

cmake_minimum_required (VERSION 2.6.2)
project (PetIGA C)

if (0)
  # Use Jed Brown's FindPETSc.cmake
  set (CMAKE_MODULE_PATH ${PetIGA_SOURCE_DIR}/conf/cmake)
  find_package (PETSc)
else ()
  find_path (PETSC_DIR include/petsc.h HINTS ENV PETSC_DIR PATHS $ENV{HOME}/petsc DOC "PETSc top-level directory")
  set (PETSC_ARCH $ENV{PETSC_ARCH} CACHE STRING "PETSc configuration")
  find_path (PETSC_INCLUDE_DIR  petsc.h HINTS "${PETSC_DIR}" PATH_SUFFIXES include NO_DEFAULT_PATH)
  find_path (PETSC_INCLUDE_CONF petscconf.h HINTS "${PETSC_DIR}" PATH_SUFFIXES "${PETSC_ARCH}/include" "include" NO_DEFAULT_PATH)
  mark_as_advanced (PETSC_INCLUDE_DIR PETSC_INCLUDE_CONF)
  set (PETSC_INCLUDES ${PETSC_INCLUDE_CONF} ${PETSC_INCLUDE_DIR} CACHE PATH "PETSc include paths" FORCE)
  set (PETSC_DEFINITIONS "-D__INSDIR__=" CACHE STRING "PETSc preprocesor definitions" FORCE)
  mark_as_advanced (PETSC_DEFINITIONS)
  find_library (PETSC_LIBRARIES NAMES petsc HINTS "${PETSC_DIR}" PATH_SUFFIXES "${PETSC_ARCH}/lib" "lib" NO_DEFAULT_PATH)
  include (${PETSC_DIR}/${PETSC_ARCH}/conf/PETScConfig.cmake)
  mark_as_advanced (PETSC_CLANGUAGE_Cxx)
endif ()

if (PETSC_CLANGUAGE_Cxx)
  enable_language (CXX)
endif ()
enable_language (Fortran)

include_directories (${PETSC_INCLUDES} ${PETSC_PACKAGE_INCLUDES}
                    "${PetIGA_SOURCE_DIR}/${PETSC_ARCH}/include"
                    "${PetIGA_SOURCE_DIR}/include")
add_definitions (${PETSC_DEFINITIONS})

set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PetIGA_BINARY_DIR}/lib"     CACHE PATH "Output directory for PetIGA archives")
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PetIGA_BINARY_DIR}/lib"     CACHE PATH "Output directory for PetIGA libraries")
set (CMAKE_Fortran_MODULE_DIRECTORY "${PetIGA_BINARY_DIR}/include" CACHE PATH "Output directory for Fortran modules")
mark_as_advanced (CMAKE_ARCHIVE_OUTPUT_DIRECTORY CMAKE_LIBRARY_OUTPUT_DIRECTORY CMAKE_Fortran_MODULE_DIRECTORY)
set (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

file (GLOB PetIGA_SOURCES_C RELATIVE ${PetIGA_SOURCE_DIR} ${PetIGA_SOURCE_DIR}/src/*.c)
file (GLOB PetIGA_SOURCES_F RELATIVE ${PetIGA_SOURCE_DIR} ${PetIGA_SOURCE_DIR}/src/*.[Ff]90)
set  (PetIGA_SOURCES_ALL ${PetIGA_SOURCES_C} ${PetIGA_SOURCES_F})
if (PETSC_CLANGUAGE_Cxx)
  foreach (file ${PetIGA_SOURCES_C})
    set_source_files_properties(${file} PROPERTIES LANGUAGE CXX)
  endforeach ()
endif ()

add_library (petiga ${PetIGA_SOURCES_ALL})
target_link_libraries (petiga ${PETSC_LIBRARIES} ${PETSC_PACKAGE_LIBS})

#set (BUILD_SHARED_LIBS NO)

#if (BUILD_SHARED_LIBS)
#  add_library (petiga-static STATIC ${PetIGA_SOURCES_ALL})
#  set_target_properties (petiga-static PROPERTIES OUTPUT_NAME "petiga")
#  set_target_properties (petiga-static PROPERTIES PREFIX "lib")
#endif()

if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
  set (CMAKE_INSTALL_PREFIX "$ENV{HOME}/petiga" CACHE PATH "PetIGA install prefix" FORCE)
endif ()
install (TARGETS   petiga LIBRARY         DESTINATION lib)
install (DIRECTORY conf/                  DESTINATION conf    FILES_MATCHING PATTERN "petiga*")
install (DIRECTORY include/               DESTINATION include FILES_MATCHING PATTERN "*.h"    )
install (DIRECTORY ${PETSC_ARCH}/include/ DESTINATION include FILES_MATCHING PATTERN "*.h"    )
install (DIRECTORY ${PETSC_ARCH}/include/ DESTINATION include FILES_MATCHING PATTERN "*.mod"  )
install (CODE "execute_process(COMMAND sed -i -e s/.{PETSC_ARCH}.//g ${CMAKE_INSTALL_PREFIX}/conf/petigavariables)")
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.