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()
|
|
|
|
|
2016-12-13 18:09:13 +00:00
|
|
|
PROJECT(openEMS CXX C)
|
2023-01-06 19:05:13 +00:00
|
|
|
cmake_minimum_required(VERSION 3.0)
|
2014-09-18 19:12:50 +00:00
|
|
|
|
2015-12-19 14:01:56 +00:00
|
|
|
# default
|
|
|
|
set(LIB_VERSION_MAJOR 0)
|
|
|
|
set(LIB_VERSION_MINOR 0)
|
2023-10-22 14:25:51 +00:00
|
|
|
set(LIB_VERSION_PATCH 36)
|
2015-12-19 14:01:56 +00:00
|
|
|
set(LIB_VERSION_STRING ${LIB_VERSION_MAJOR}.${LIB_VERSION_MINOR}.${LIB_VERSION_PATCH})
|
|
|
|
|
|
|
|
set(VERSION "v${LIB_VERSION_STRING}")
|
|
|
|
|
2014-09-21 18:19:21 +00:00
|
|
|
IF(EXISTS ${PROJECT_SOURCE_DIR}/localConfig.cmake)
|
|
|
|
include(${PROJECT_SOURCE_DIR}/localConfig.cmake)
|
|
|
|
ENDIF()
|
|
|
|
|
2019-12-30 16:12:51 +00:00
|
|
|
#ADD_DEFINITIONS( -D__SSE2__ )
|
|
|
|
|
2023-10-22 14:25:51 +00:00
|
|
|
set(VERSION "v0.0.36")
|
2015-08-05 19:23:31 +00:00
|
|
|
|
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
|
2015-09-25 18:22:47 +00:00
|
|
|
LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" isSystemDir)
|
2014-09-21 20:44:51 +00:00
|
|
|
IF("${isSystemDir}" STREQUAL "-1")
|
2015-09-25 18:22:47 +00:00
|
|
|
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}")
|
2014-09-21 20:44:51 +00:00
|
|
|
ENDIF("${isSystemDir}" STREQUAL "-1")
|
|
|
|
endif()
|
|
|
|
if(APPLE AND NOT CMAKE_INSTALL_NAME_DIR)
|
2015-09-25 18:22:47 +00:00
|
|
|
set(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}")
|
2014-09-21 20:44:51 +00:00
|
|
|
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
|
|
|
|
2016-01-27 17:37:07 +00:00
|
|
|
if (WITH_MPI)
|
|
|
|
ADD_DEFINITIONS(-DMPI_SUPPORT)
|
|
|
|
# Require MPI for this project:
|
|
|
|
find_package(MPI REQUIRED)
|
|
|
|
INCLUDE_DIRECTORIES( ${MPI_INCLUDE_PATH} )
|
|
|
|
|
|
|
|
message(STATUS "Found MPI. INCLUDE " ${MPI_INCLUDE_PATH})
|
|
|
|
endif()
|
|
|
|
|
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)
|
2015-05-22 19:04:47 +00:00
|
|
|
find_library(fparser_LIBRARIES
|
|
|
|
NAMES fparser
|
2015-09-25 18:22:47 +00:00
|
|
|
HINTS ${FPARSER_ROOT_DIR}/lib${LIB_SUFFIX}
|
2015-05-22 19:04:47 +00:00
|
|
|
NO_CMAKE_FIND_ROOT_PATH
|
2014-09-21 18:19:21 +00:00
|
|
|
)
|
|
|
|
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
|
2015-09-25 18:22:47 +00:00
|
|
|
HINTS ${CSXCAD_ROOT_DIR}/lib${LIB_SUFFIX}
|
2015-05-22 19:04:47 +00:00
|
|
|
NO_CMAKE_FIND_ROOT_PATH
|
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}
|
2015-05-22 19:04:47 +00:00
|
|
|
NO_CMAKE_FIND_ROOT_PATH
|
2015-05-19 20:13:28 +00:00
|
|
|
)
|
|
|
|
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 )
|
2019-12-30 16:12:51 +00:00
|
|
|
message(STATUS "TinyXML_INCLUDE_DIR: ${TinyXML_INCLUDE_DIR}")
|
|
|
|
message(STATUS "TinyXML_LIBRARY: ${TinyXML_LIBRARY}")
|
|
|
|
|
|
|
|
INCLUDE_DIRECTORIES( ${TinyXML_INCLUDE_DIR} )
|
2014-09-18 19:12:50 +00:00
|
|
|
|
2015-05-04 18:01:23 +00:00
|
|
|
# hdf5
|
2015-09-29 17:56:27 +00:00
|
|
|
find_package(HDF5 1.8 COMPONENTS C HL REQUIRED)
|
2016-11-15 19:13:05 +00:00
|
|
|
INCLUDE_DIRECTORIES (${HDF5_INCLUDE_DIRS})
|
2016-10-05 18:25:26 +00:00
|
|
|
link_directories(${HDF5_LIBRARIES})
|
2019-12-30 16:12:51 +00:00
|
|
|
# hdf5 compat
|
|
|
|
#ADD_DEFINITIONS( -DH5_USE_16_API )
|
2021-07-08 13:15:55 +00:00
|
|
|
#ADD_DEFINITIONS( -DH5_BUILT_AS_DYNAMIC_LIB )
|
2014-09-18 19:12:50 +00:00
|
|
|
|
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
|
2019-12-30 16:12:51 +00:00
|
|
|
REQUIRED
|
2014-09-18 19:12:50 +00:00
|
|
|
)
|
2020-02-13 21:49:07 +00:00
|
|
|
message(STATUS "Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}")
|
2019-12-30 16:12:51 +00:00
|
|
|
message(STATUS "Boost_LIBRARIES: ${Boost_LIBRARIES}")
|
2020-02-13 21:49:07 +00:00
|
|
|
INCLUDE_DIRECTORIES (${Boost_INCLUDE_DIRS})
|
2014-09-18 19:12:50 +00:00
|
|
|
|
2015-05-05 20:05:25 +00:00
|
|
|
# vtk
|
2018-12-26 20:08:18 +00:00
|
|
|
find_package(VTK COMPONENTS vtkIOXML vtkIOGeometry vtkIOLegacy vtkIOPLY NO_MODULE REQUIRED)
|
2015-05-19 20:13:28 +00:00
|
|
|
|
|
|
|
message(STATUS "Found package VTK. Using version " ${VTK_VERSION})
|
2023-01-06 19:05:13 +00:00
|
|
|
set( vtk_LIBS ${VTK_LIBRARIES} )
|
2015-11-13 20:43:00 +00:00
|
|
|
message(STATUS "vtk libraries " ${vtk_LIBS})
|
2014-09-18 19:12:50 +00:00
|
|
|
|
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})
|
|
|
|
|
2019-09-07 20:30:45 +00:00
|
|
|
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
|
|
|
|
set(ARCH "x86_64")
|
|
|
|
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "amd64")
|
|
|
|
set(ARCH "x86_64")
|
|
|
|
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64")
|
|
|
|
set(ARCH "x86_64")
|
2021-10-01 11:40:24 +00:00
|
|
|
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(ppc64.*|PPC64.*|powerpc64.*)")
|
2019-09-07 20:30:45 +00:00
|
|
|
set(ARCH "ppc64")
|
2023-01-06 08:38:41 +00:00
|
|
|
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^(aarch64|arm64)")
|
2022-12-07 20:11:51 +00:00
|
|
|
set(ARCH "aarch64")
|
2019-09-07 20:30:45 +00:00
|
|
|
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "unknown")
|
|
|
|
set(ARCH "unknown")
|
|
|
|
message(FATAL_ERROR "Unable to determine target architecture! Try setting CMAKE_SYSTEM_PROCESSOR to a valid value.")
|
|
|
|
else()
|
|
|
|
set(ARCH "unsupported")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(${ARCH} STREQUAL "x86_64")
|
|
|
|
message(STATUS "Detected 64-bit x86 target")
|
2023-05-12 14:21:17 +00:00
|
|
|
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse -march=native")
|
2019-09-07 20:30:45 +00:00
|
|
|
elseif(${ARCH} STREQUAL "ppc64")
|
|
|
|
message(STATUS "Detected 64-bit POWER target")
|
2023-05-12 14:21:17 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNO_WARN_X86_INTRINSICS -DSSE_CORRECT_DENORMALS")
|
2022-12-07 20:11:51 +00:00
|
|
|
elseif(${ARCH} STREQUAL "aarch64")
|
|
|
|
message(STATUS "Detected 64-bit ARM target")
|
2023-05-12 14:21:17 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNO_WARN_X86_INTRINSICS -DSSE_CORRECT_DENORMALS")
|
2019-09-07 20:30:45 +00:00
|
|
|
elseif(${ARCH} STREQUAL "unsupported")
|
|
|
|
message(FATAL_ERROR "Unsupported target architecture! Try porting openEMS to your architecture...")
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Unable to determine target architecture! Aborting.")
|
|
|
|
endif()
|
2015-05-19 20:13:28 +00:00
|
|
|
|
2014-09-18 19:12:50 +00:00
|
|
|
# independent tool
|
|
|
|
ADD_SUBDIRECTORY( nf2ff )
|
|
|
|
|
2015-12-19 14:01:56 +00:00
|
|
|
set(SOURCES
|
|
|
|
openems.cpp
|
|
|
|
)
|
|
|
|
|
2019-12-30 19:04:22 +00:00
|
|
|
set(PUB_HEADERS openems.h openems_global.h)
|
2016-08-17 21:50:26 +00:00
|
|
|
|
2014-09-18 19:12:50 +00:00
|
|
|
# libs
|
|
|
|
ADD_SUBDIRECTORY( tools )
|
|
|
|
ADD_SUBDIRECTORY( FDTD )
|
|
|
|
ADD_SUBDIRECTORY( FDTD/extensions )
|
|
|
|
ADD_SUBDIRECTORY( Common )
|
|
|
|
|
|
|
|
INCLUDE_DIRECTORIES( ${openEMS_SOURCE_DIR} ) #find tools
|
|
|
|
|
2015-12-19 14:01:56 +00:00
|
|
|
message(STATUS "Sources:" ${SOURCES})
|
2014-09-18 19:12:50 +00:00
|
|
|
|
2016-01-31 12:31:52 +00:00
|
|
|
if (${MPI_CXX_FOUND})
|
2016-01-27 17:37:07 +00:00
|
|
|
set(CMAKE_CXX_COMPILE_FLAGS ${CMAKE_CXX_COMPILE_FLAGS} ${MPI_COMPILE_FLAGS})
|
|
|
|
set(CMAKE_CXX_LINK_FLAGS ${CMAKE_CXX_LINK_FLAGS} ${MPI_LINK_FLAGS})
|
2016-01-31 12:31:52 +00:00
|
|
|
SET(CMAKE_CXX_COMPILER ${MPI_CXX_COMPILER})
|
2016-01-27 17:37:07 +00:00
|
|
|
endif()
|
|
|
|
|
2015-12-19 14:01:56 +00:00
|
|
|
add_library( openEMS SHARED ${SOURCES})
|
2019-12-30 16:12:51 +00:00
|
|
|
#ADD_EXECUTABLE( openEMS main.cpp ${SOURCES})
|
|
|
|
set_target_properties(openEMS PROPERTIES VERSION ${LIB_VERSION_STRING} SOVERSION ${LIB_VERSION_MAJOR} )
|
2014-09-18 19:12:50 +00:00
|
|
|
TARGET_LINK_LIBRARIES( openEMS
|
2014-09-24 17:51:11 +00:00
|
|
|
${CSXCAD_LIBRARIES}
|
|
|
|
${fparser_LIBRARIES}
|
2019-12-30 16:12:51 +00:00
|
|
|
${TinyXML_LIBRARY}
|
2015-05-19 20:13:28 +00:00
|
|
|
${HDF5_LIBRARIES}
|
2016-12-13 18:09:13 +00:00
|
|
|
${HDF5_HL_LIBRARIES}
|
2014-09-18 19:12:50 +00:00
|
|
|
${Boost_LIBRARIES}
|
|
|
|
${vtk_LIBS}
|
2016-01-27 17:37:07 +00:00
|
|
|
${MPI_LIBRARIES}
|
2014-09-18 19:12:50 +00:00
|
|
|
)
|
|
|
|
|
2019-12-30 16:12:51 +00:00
|
|
|
if (WIN32)
|
|
|
|
# make sure "BUILD_OPENEMS_LIB" is only set for openEMS (dll) not openEMS_bin (exe)
|
|
|
|
target_compile_definitions(openEMS PRIVATE -DBUILD_OPENEMS_LIB )
|
|
|
|
endif (WIN32)
|
|
|
|
|
2015-12-19 14:01:56 +00:00
|
|
|
# main program
|
|
|
|
ADD_EXECUTABLE( openEMS_bin main.cpp )
|
|
|
|
SET_TARGET_PROPERTIES(openEMS_bin PROPERTIES OUTPUT_NAME openEMS)
|
|
|
|
TARGET_LINK_LIBRARIES(openEMS_bin openEMS)
|
|
|
|
|
2019-12-30 16:12:51 +00:00
|
|
|
if (WIN32)
|
|
|
|
INSTALL(TARGETS openEMS DESTINATION bin)
|
|
|
|
else()
|
|
|
|
INSTALL(TARGETS openEMS DESTINATION lib${LIB_SUFFIX})
|
|
|
|
endif()
|
|
|
|
INSTALL(TARGETS openEMS_bin DESTINATION bin)
|
2016-01-27 17:37:07 +00:00
|
|
|
|
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)
|
2016-01-27 17:37:07 +00:00
|
|
|
if (WITH_MPI)
|
|
|
|
INSTALL( FILES openEMS_MPI.sh
|
|
|
|
DESTINATION bin
|
|
|
|
PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE)
|
|
|
|
endif()
|
2015-05-19 20:13:28 +00:00
|
|
|
endif ()
|
2016-08-17 21:50:26 +00:00
|
|
|
INSTALL(FILES ${PUB_HEADERS} DESTINATION include/openEMS)
|
2014-09-18 19:12:50 +00:00
|
|
|
INSTALL( DIRECTORY matlab DESTINATION share/openEMS )
|
|
|
|
# TODO mpi, tarball, debug, release
|