From 29ffbb66abd9157d042739685c45bb1c34ab5267 Mon Sep 17 00:00:00 2001 From: Thorsten Liebig Date: Tue, 19 May 2015 22:13:28 +0200 Subject: [PATCH] cmake: improve build system and support win32 Signed-off-by: Thorsten Liebig --- CMakeLists.txt | 40 ++++++++++++++++++++++++---------- Common/CMakeLists.txt | 2 +- FDTD/CMakeLists.txt | 2 +- FDTD/engine_multithread.h | 6 ++--- FDTD/extensions/CMakeLists.txt | 2 +- nf2ff/CMakeLists.txt | 3 +-- tools/CMakeLists.txt | 2 +- 7 files changed, 36 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 68c4f7b..5d90b26 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,13 +66,19 @@ INCLUDE_DIRECTORIES( ${FPARSER_ROOT_DIR}/include ) # CSXCAD # $ cmake -D CSXCAD_ROOT_DIR=~/opt/openEMS . # SET(CSXCAD_ROOT_DIR ~/opt/openEMS) -find_library(CSXCAD_LIBRARIES NAMES CSXCAD - HINTS - ${CSXCAD_ROOT_DIR}/lib +find_library(CSXCAD_LIBRARIES + NAMES CSXCAD + HINTS ${CSXCAD_ROOT_DIR}/lib ) -message(STATUS "CSXCAD: ${CSXCAD_LIBRARIES}" ) +message(STATUS "CSXCAD_LIBRARIES: ${CSXCAD_LIBRARIES}" ) #TODO test if CSXCADs was found -INCLUDE_DIRECTORIES( ${CSXCAD_ROOT_DIR}/include/CSXCAD ) +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} ) # TinyXML module from https://github.com/ros/cmake_modules find_package(TinyXML REQUIRED) @@ -96,7 +102,14 @@ find_package(Boost 1.46 COMPONENTS ) # vtk -find_package(VTK REQUIRED) +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}) if("${VTK_MAJOR_VERSION}" EQUAL 6) set( vtk_LIBS vtkCommonCore @@ -105,7 +118,6 @@ if("${VTK_MAJOR_VERSION}" EQUAL 6) vtkIOXML vtkIOGeometry vtkIOPLY - vtkIOMPIParallel vtksys vtkIOCore ) @@ -122,10 +134,13 @@ else() ) endif() -message(STATUS "Found package VTK. Using version " ${VTK_VERSION}) include(${VTK_USE_FILE}) INCLUDE_DIRECTORIES (${VTK_INCLUDE_DIR}) +if(WIN32) + set(CMAKE_CXX_FLAGS "-msse") +endif() + # independent tool ADD_SUBDIRECTORY( nf2ff ) @@ -155,16 +170,17 @@ TARGET_LINK_LIBRARIES( openEMS ${CSXCAD_LIBRARIES} ${fparser_LIBRARIES} tinyxml - hdf5 - hdf5_hl + ${HDF5_LIBRARIES} ${Boost_LIBRARIES} ${vtk_LIBS} ) + INSTALL( TARGETS openEMS DESTINATION bin ) -INSTALL( FILES openEMS.sh +if (UNIX) + INSTALL( FILES openEMS.sh DESTINATION bin PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE) - +endif () INSTALL( DIRECTORY matlab DESTINATION share/openEMS ) # TODO mpi, tarball, debug, release diff --git a/Common/CMakeLists.txt b/Common/CMakeLists.txt index 0b3abfe..c2c44a3 100644 --- a/Common/CMakeLists.txt +++ b/Common/CMakeLists.txt @@ -17,5 +17,5 @@ set( SOURCES ) # Common lib -add_library( Common ${SOURCES} ) +add_library( Common STATIC ${SOURCES} ) diff --git a/FDTD/CMakeLists.txt b/FDTD/CMakeLists.txt index a84d8b9..bbef2f2 100644 --- a/FDTD/CMakeLists.txt +++ b/FDTD/CMakeLists.txt @@ -21,5 +21,5 @@ set(SOURCES ) # FDTD lib -add_library( FDTD ${SOURCES} ) +add_library( FDTD STATIC ${SOURCES} ) diff --git a/FDTD/engine_multithread.h b/FDTD/engine_multithread.h index f0c8a5a..20e7073 100644 --- a/FDTD/engine_multithread.h +++ b/FDTD/engine_multithread.h @@ -26,9 +26,9 @@ #include #include -#ifdef WIN32 -#include // for struct timeval -#endif +//#ifdef WIN32 +//#include // for struct timeval +//#endif #include diff --git a/FDTD/extensions/CMakeLists.txt b/FDTD/extensions/CMakeLists.txt index e725f1e..f60cae3 100644 --- a/FDTD/extensions/CMakeLists.txt +++ b/FDTD/extensions/CMakeLists.txt @@ -26,5 +26,5 @@ set(SOURCES ) # FDTD/extensions lib -add_library( extensions ${SOURCES} ) +add_library( extensions STATIC ${SOURCES} ) diff --git a/nf2ff/CMakeLists.txt b/nf2ff/CMakeLists.txt index be26bf2..a9ddef1 100644 --- a/nf2ff/CMakeLists.txt +++ b/nf2ff/CMakeLists.txt @@ -25,8 +25,7 @@ ADD_EXECUTABLE( nf2ff ${SOURCES} ) TARGET_LINK_LIBRARIES( nf2ff tools tinyxml - hdf5 - hdf5_hl + ${HDF5_LIBRARIES} ${Boost_LIBRARIES} ) diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index a377a52..d66a1e2 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -22,5 +22,5 @@ set(SOURCES #) # tools lib -add_library(tools ${SOURCES} ) +add_library(tools STATIC ${SOURCES} )