2014-09-18 19:12:50 +00:00
|
|
|
|
2014-10-06 19:23:36 +00:00
|
|
|
# define build type
|
|
|
|
IF( DEFINED CMAKE_BUILD_TYPE )
|
|
|
|
SET( CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Set to either \"Release\" or \"Debug\"" )
|
|
|
|
ELSE()
|
|
|
|
SET( CMAKE_BUILD_TYPE Release CACHE STRING "Set to either \"Release\" or \"Debug\"" )
|
|
|
|
ENDIF()
|
|
|
|
|
2014-09-18 19:12:50 +00:00
|
|
|
PROJECT(openEMS CXX)
|
|
|
|
cmake_minimum_required(VERSION 2.8)
|
|
|
|
|
2014-09-21 18:19:21 +00:00
|
|
|
IF(EXISTS ${PROJECT_SOURCE_DIR}/localConfig.cmake)
|
|
|
|
include(${PROJECT_SOURCE_DIR}/localConfig.cmake)
|
|
|
|
ENDIF()
|
|
|
|
|
2014-09-18 19:12:50 +00:00
|
|
|
# add git revision
|
|
|
|
IF(EXISTS ${PROJECT_SOURCE_DIR}/.git )
|
|
|
|
FIND_PACKAGE(Git)
|
|
|
|
# Get the latest abbreviated commit hash of the working branch
|
|
|
|
execute_process(
|
|
|
|
COMMAND ${GIT_EXECUTABLE} describe --tags
|
|
|
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
|
|
|
OUTPUT_VARIABLE GITREV
|
|
|
|
)
|
|
|
|
set(VERSION ${GITREV})
|
|
|
|
string(STRIP ${VERSION} VERSION)
|
|
|
|
message(STATUS "Found Git repository, ${PROJECT_NAME} version tag: ${VERSION}")
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
ADD_DEFINITIONS(-DGIT_VERSION=\"${VERSION}\")
|
|
|
|
|
2014-09-21 20:44:51 +00:00
|
|
|
#
|
|
|
|
# Set up RPATH for the project
|
|
|
|
#
|
|
|
|
option(ENABLE_RPATH "Enable rpath support on Linux and Mac" ON)
|
|
|
|
if(NOT CMAKE_INSTALL_RPATH)
|
|
|
|
# the RPATH to be used when installing, but only if it's not a system directory
|
|
|
|
LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
|
|
|
|
IF("${isSystemDir}" STREQUAL "-1")
|
|
|
|
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
|
|
|
|
ENDIF("${isSystemDir}" STREQUAL "-1")
|
|
|
|
endif()
|
|
|
|
if(APPLE AND NOT CMAKE_INSTALL_NAME_DIR)
|
|
|
|
set(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib")
|
|
|
|
endif()
|
|
|
|
if(UNIX AND ENABLE_RPATH)
|
|
|
|
set(CMAKE_SKIP_BUILD_RPATH FALSE)
|
|
|
|
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
|
|
|
|
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
|
|
|
endif()
|
2014-09-21 18:19:21 +00:00
|
|
|
|
2014-09-18 19:12:50 +00:00
|
|
|
# Set locations of extra CMake modules
|
2014-09-18 20:54:19 +00:00
|
|
|
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${openEMS_SOURCE_DIR}/cmake/Modules/")
|
2014-09-18 19:12:50 +00:00
|
|
|
|
2014-09-21 18:19:21 +00:00
|
|
|
# fparser
|
|
|
|
# $ cmake -D FPARSER_ROOT_DIR=~/opt/openEMS .
|
|
|
|
# SET(FPARSER_ROOT_DIR ~/opt/openEMS)
|
|
|
|
find_library(fparser_LIBRARIES NAMES fparser
|
|
|
|
HINTS
|
|
|
|
${FPARSER_ROOT_DIR}/lib
|
|
|
|
)
|
|
|
|
message(STATUS "fparser: ${fparser_LIBRARIES}" )
|
|
|
|
#TODO test if fparser was found
|
|
|
|
INCLUDE_DIRECTORIES( ${FPARSER_ROOT_DIR}/include )
|
|
|
|
|
|
|
|
# CSXCAD
|
|
|
|
# $ cmake -D CSXCAD_ROOT_DIR=~/opt/openEMS .
|
|
|
|
# SET(CSXCAD_ROOT_DIR ~/opt/openEMS)
|
2015-05-19 20:13:28 +00:00
|
|
|
find_library(CSXCAD_LIBRARIES
|
|
|
|
NAMES CSXCAD
|
|
|
|
HINTS ${CSXCAD_ROOT_DIR}/lib
|
2014-09-21 18:19:21 +00:00
|
|
|
)
|
2015-05-19 20:13:28 +00:00
|
|
|
message(STATUS "CSXCAD_LIBRARIES: ${CSXCAD_LIBRARIES}" )
|
2014-09-21 18:19:21 +00:00
|
|
|
#TODO test if CSXCADs was found
|
2015-05-19 20:13:28 +00:00
|
|
|
find_path(CSXCAD_INCLUDE_DIR
|
|
|
|
NAMES ContinuousStructure.h
|
|
|
|
HINTS ${CSXCAD_ROOT_DIR}/include
|
|
|
|
PATH_SUFFIXES "CSXCAD" ${CSXCAD_INCLUDE_DIR}
|
|
|
|
)
|
|
|
|
message(STATUS "CSXCAD_INCLUDE_DIR: ${CSXCAD_INCLUDE_DIR}" )
|
|
|
|
INCLUDE_DIRECTORIES( ${CSXCAD_INCLUDE_DIR} )
|
2014-09-21 18:19:21 +00:00
|
|
|
|
2014-09-18 19:12:50 +00:00
|
|
|
# TinyXML module from https://github.com/ros/cmake_modules
|
|
|
|
find_package(TinyXML REQUIRED)
|
|
|
|
ADD_DEFINITIONS( -DTIXML_USE_STL )
|
|
|
|
|
2015-05-04 18:01:23 +00:00
|
|
|
# hdf5
|
2014-09-18 19:12:50 +00:00
|
|
|
find_package(HDF5 REQUIRED)
|
|
|
|
INCLUDE_DIRECTORIES (${HDF5_INCLUDE_DIR})
|
2015-05-04 18:01:23 +00:00
|
|
|
link_directories(${HDF5_LIBRARY_DIRS})
|
2014-09-18 19:12:50 +00:00
|
|
|
|
|
|
|
# hdf5 compat
|
|
|
|
ADD_DEFINITIONS( -DH5_USE_16_API )
|
|
|
|
|
2015-05-04 18:01:23 +00:00
|
|
|
# boost
|
2014-09-18 19:12:50 +00:00
|
|
|
find_package(Boost 1.46 COMPONENTS
|
|
|
|
thread
|
|
|
|
system
|
|
|
|
date_time
|
|
|
|
serialization
|
|
|
|
chrono
|
|
|
|
)
|
|
|
|
|
2015-05-05 20:05:25 +00:00
|
|
|
# vtk
|
2015-05-19 20:13:28 +00:00
|
|
|
if (WIN32)
|
|
|
|
find_package(VTK 6.1 REQUIRED)
|
|
|
|
else()
|
|
|
|
# prefer >=6.1, fallback to >=5.4
|
|
|
|
find_package(VTK REQUIRED)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
message(STATUS "Found package VTK. Using version " ${VTK_VERSION})
|
2014-09-18 19:12:50 +00:00
|
|
|
if("${VTK_MAJOR_VERSION}" EQUAL 6)
|
2015-05-05 20:05:25 +00:00
|
|
|
set( vtk_LIBS
|
|
|
|
vtkCommonCore
|
|
|
|
vtkCommonDataModel
|
|
|
|
vtkIOLegacy
|
|
|
|
vtkIOXML
|
|
|
|
vtkIOGeometry
|
|
|
|
vtkIOPLY
|
|
|
|
vtksys
|
|
|
|
vtkIOCore
|
|
|
|
)
|
|
|
|
else()
|
|
|
|
set( vtk_LIBS
|
|
|
|
vtkCommon
|
|
|
|
vtkFiltering
|
|
|
|
vtkGraphics
|
|
|
|
vtkHybrid
|
|
|
|
vtkIO
|
|
|
|
vtkRendering
|
|
|
|
vtkWidgets
|
|
|
|
QVTK
|
|
|
|
)
|
2014-09-18 19:12:50 +00:00
|
|
|
endif()
|
|
|
|
|
2015-05-05 20:05:25 +00:00
|
|
|
include(${VTK_USE_FILE})
|
2014-09-18 19:12:50 +00:00
|
|
|
INCLUDE_DIRECTORIES (${VTK_INCLUDE_DIR})
|
|
|
|
|
2015-05-19 20:13:28 +00:00
|
|
|
if(WIN32)
|
|
|
|
set(CMAKE_CXX_FLAGS "-msse")
|
|
|
|
endif()
|
|
|
|
|
2014-09-18 19:12:50 +00:00
|
|
|
# independent tool
|
|
|
|
ADD_SUBDIRECTORY( nf2ff )
|
|
|
|
|
|
|
|
# libs
|
|
|
|
ADD_SUBDIRECTORY( tools )
|
|
|
|
ADD_SUBDIRECTORY( FDTD )
|
|
|
|
ADD_SUBDIRECTORY( FDTD/extensions )
|
|
|
|
|
|
|
|
# depend on CSXCAD
|
|
|
|
ADD_SUBDIRECTORY( Common )
|
|
|
|
|
|
|
|
# main program
|
|
|
|
set(SOURCES
|
|
|
|
main.cpp
|
|
|
|
openems.cpp
|
|
|
|
)
|
|
|
|
|
|
|
|
INCLUDE_DIRECTORIES( ${openEMS_SOURCE_DIR} ) #find tools
|
|
|
|
|
|
|
|
ADD_EXECUTABLE( openEMS ${SOURCES} )
|
|
|
|
|
|
|
|
TARGET_LINK_LIBRARIES( openEMS
|
|
|
|
FDTD
|
|
|
|
Common
|
|
|
|
extensions
|
2014-09-24 17:51:11 +00:00
|
|
|
tools
|
|
|
|
${CSXCAD_LIBRARIES}
|
|
|
|
${fparser_LIBRARIES}
|
2014-09-18 19:12:50 +00:00
|
|
|
tinyxml
|
2015-05-19 20:13:28 +00:00
|
|
|
${HDF5_LIBRARIES}
|
2014-09-18 19:12:50 +00:00
|
|
|
${Boost_LIBRARIES}
|
|
|
|
${vtk_LIBS}
|
|
|
|
)
|
|
|
|
|
2015-05-19 20:13:28 +00:00
|
|
|
|
2014-09-18 19:12:50 +00:00
|
|
|
INSTALL( TARGETS openEMS DESTINATION bin )
|
2015-05-19 20:13:28 +00:00
|
|
|
if (UNIX)
|
|
|
|
INSTALL( FILES openEMS.sh
|
2015-03-04 21:44:07 +00:00
|
|
|
DESTINATION bin
|
|
|
|
PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE)
|
2015-05-19 20:13:28 +00:00
|
|
|
endif ()
|
2014-09-18 19:12:50 +00:00
|
|
|
INSTALL( DIRECTORY matlab DESTINATION share/openEMS )
|
|
|
|
# TODO mpi, tarball, debug, release
|