From: abn Date: Mon, 11 Apr 2016 08:01:10 +0000 (+0200) Subject: Added option MEDCOUPLING_BUILD_STATIC to build static libs. X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fabn%2Fstaticlib;p=tools%2Fmedcoupling.git Added option MEDCOUPLING_BUILD_STATIC to build static libs. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index b366b9307..00068d1a4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,7 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.2 FATAL_ERROR) +CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12 FATAL_ERROR) #INCLUDE(CMakeDependentOption) PROJECT(MEDCoupling C CXX) @@ -55,6 +55,7 @@ OPTION(MEDCOUPLING_WITH_FILE_EXAMPLES "Install examples of files containing mesh OPTION(MEDCOUPLING_USE_MPI "(Use MPI containers) - For MED this triggers the build of ParaMEDMEM." OFF) OPTION(MEDCOUPLING_BUILD_TESTS "Build MED tests." ON) OPTION(MEDCOUPLING_BUILD_DOC "Build MED doc." ON) +OPTION(MEDCOUPLING_BUILD_STATIC "Build MEDCoupling library in static mode." OFF) CMAKE_DEPENDENT_OPTION(MEDCOUPLING_PARTITIONER_METIS "Enable metis graph library in MEDPartitioner." ON "MEDCOUPLING_ENABLE_PARTITIONER" OFF) CMAKE_DEPENDENT_OPTION(MEDCOUPLING_PARTITIONER_SCOTCH "Enable scotch graph library in MEDPartitioner." ON "MEDCOUPLING_ENABLE_PARTITIONER;NOT MEDCOUPLING_USE_MPI" OFF) CMAKE_DEPENDENT_OPTION(MEDCOUPLING_PARTITIONER_PARMETIS "Enable parmetis graph library in MEDPartitioner." ON "MEDCOUPLING_ENABLE_PARTITIONER;MEDCOUPLING_USE_MPI" OFF) @@ -62,6 +63,13 @@ IF(WIN32) CMAKE_DEPENDENT_OPTION(MEDCOUPLING_MEDLOADER_USE_XDR "Enable use of XDR for SauvReader." ON "NOT MEDCOUPLING_MICROMED" OFF) ENDIF(WIN32) +IF(MEDCOUPLING_BUILD_STATIC) + SET(BUILD_SHARED_LIBS 0) + SET(CMAKE_POSITION_INDEPENDENT_CODE 1) # -fPIC option +ELSE() + SET(BUILD_SHARED_LIBS 1) +ENDIF() + # # Set list of prerequisites # ========================= diff --git a/src/INTERP_KERNEL/CMakeLists.txt b/src/INTERP_KERNEL/CMakeLists.txt index 29755fb07..a3ce570f3 100644 --- a/src/INTERP_KERNEL/CMakeLists.txt +++ b/src/INTERP_KERNEL/CMakeLists.txt @@ -74,7 +74,7 @@ IF(NOT WIN32) SET(PLATFORM_MMAP "-D_POSIX_MAPPED_FILES") ENDIF(NOT WIN32) -ADD_LIBRARY(interpkernel SHARED ${interpkernel_SOURCES}) +ADD_LIBRARY(interpkernel ${interpkernel_SOURCES}) SET_TARGET_PROPERTIES(interpkernel PROPERTIES COMPILE_FLAGS "${PLATFORM_MMAP}") TARGET_LINK_LIBRARIES(interpkernel ${PLATFORM_LIBS}) INSTALL(TARGETS interpkernel EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${MEDCOUPLING_INSTALL_LIBS}) diff --git a/src/INTERP_KERNELTest/CMakeLists.txt b/src/INTERP_KERNELTest/CMakeLists.txt index a8acafd7c..40d2922a3 100644 --- a/src/INTERP_KERNELTest/CMakeLists.txt +++ b/src/INTERP_KERNELTest/CMakeLists.txt @@ -85,8 +85,8 @@ IF(NOT MEDCOUPLING_MICROMED) INSTALL(TARGETS PerfTest DESTINATION ${MEDCOUPLING_INSTALL_BINS}) ENDIF(NOT MEDCOUPLING_MICROMED) -ADD_LIBRARY(InterpKernelTestUtils SHARED ${InterpKernelTestUtils_SOURCES}) -ADD_LIBRARY(InterpKernelTest SHARED ${InterpKernelTest_SOURCES}) +ADD_LIBRARY(InterpKernelTestUtils ${InterpKernelTestUtils_SOURCES}) +ADD_LIBRARY(InterpKernelTest ${InterpKernelTest_SOURCES}) SET(InterpKernelTest_LIBS medcoupling interpkernel ${CPPUNIT_LIBRARIES}) IF(NOT MEDCOUPLING_MICROMED) diff --git a/src/MEDCoupling/CMakeLists.txt b/src/MEDCoupling/CMakeLists.txt index 61aae93d7..6a49d3a07 100644 --- a/src/MEDCoupling/CMakeLists.txt +++ b/src/MEDCoupling/CMakeLists.txt @@ -66,11 +66,11 @@ SET(medcouplingremapper_SOURCES MEDCouplingRemapper.cxx ) -ADD_LIBRARY(medcoupling SHARED ${medcoupling_SOURCES}) +ADD_LIBRARY(medcoupling ${medcoupling_SOURCES}) TARGET_LINK_LIBRARIES(medcoupling interpkernel) INSTALL(TARGETS medcoupling EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${MEDCOUPLING_INSTALL_LIBS}) -ADD_LIBRARY(medcouplingremapper SHARED ${medcouplingremapper_SOURCES}) +ADD_LIBRARY(medcouplingremapper ${medcouplingremapper_SOURCES}) TARGET_LINK_LIBRARIES(medcouplingremapper medcoupling) INSTALL(TARGETS medcouplingremapper EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${MEDCOUPLING_INSTALL_LIBS}) diff --git a/src/MEDLoader/CMakeLists.txt b/src/MEDLoader/CMakeLists.txt index e62575173..6d0ed57c6 100644 --- a/src/MEDLoader/CMakeLists.txt +++ b/src/MEDLoader/CMakeLists.txt @@ -73,7 +73,7 @@ SET(medloader_SOURCES SauvWriter.cxx ) -ADD_LIBRARY(medloader SHARED ${medloader_SOURCES}) +ADD_LIBRARY(medloader ${medloader_SOURCES}) SET_TARGET_PROPERTIES(medloader PROPERTIES COMPILE_FLAGS "") TARGET_LINK_LIBRARIES(medloader medcoupling ${MEDFILE_C_LIBRARIES} ${HDF5_LIBRARIES} ${MEDLOADER_XDR_LIBRARIES}) INSTALL(TARGETS medloader EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${MEDCOUPLING_INSTALL_LIBS}) diff --git a/src/MEDPartitioner/CMakeLists.txt b/src/MEDPartitioner/CMakeLists.txt index f7c7f874f..981fc949a 100644 --- a/src/MEDPartitioner/CMakeLists.txt +++ b/src/MEDPartitioner/CMakeLists.txt @@ -136,7 +136,7 @@ ENDIF(${MEDCOUPLING_USE_MPI}) ADD_DEFINITIONS(${medpartitionercpp_DEFINITIONS}) -ADD_LIBRARY(medpartitionercpp SHARED ${medpartitionercpp_SOURCES}) +ADD_LIBRARY(medpartitionercpp ${medpartitionercpp_SOURCES}) TARGET_LINK_LIBRARIES(medpartitionercpp ${medpartitionercpp_LDFLAGS} ${PLATFORM_LIBS} ${PTHREAD_LIBS}) INSTALL(TARGETS medpartitionercpp DESTINATION ${MEDCOUPLING_INSTALL_LIBS}) diff --git a/src/MEDPartitioner/Test/CMakeLists.txt b/src/MEDPartitioner/Test/CMakeLists.txt index 778abe997..37151c482 100644 --- a/src/MEDPartitioner/Test/CMakeLists.txt +++ b/src/MEDPartitioner/Test/CMakeLists.txt @@ -41,7 +41,7 @@ IF(MEDCOUPLING_USE_MPI) ENDIF(MEDCOUPLING_PARTITIONER_PARMETIS) ENDIF(MEDCOUPLING_USE_MPI) -ADD_LIBRARY(MEDPARTITIONERTest SHARED ${MEDPARTITIONERTest_SOURCES}) +ADD_LIBRARY(MEDPARTITIONERTest ${MEDPARTITIONERTest_SOURCES}) TARGET_LINK_LIBRARIES(MEDPARTITIONERTest ${MEDPARTITIONERTest_LDFLAGS}) INSTALL(TARGETS MEDPARTITIONERTest DESTINATION ${MEDCOUPLING_INSTALL_LIBS}) diff --git a/src/ParaMEDLoader/CMakeLists.txt b/src/ParaMEDLoader/CMakeLists.txt index 9a3ca9264..46753e9a9 100644 --- a/src/ParaMEDLoader/CMakeLists.txt +++ b/src/ParaMEDLoader/CMakeLists.txt @@ -41,7 +41,7 @@ SET(paramedloader_SOURCES ParaMEDFileMesh.cxx ) -ADD_LIBRARY(paramedloader SHARED ${paramedloader_SOURCES}) +ADD_LIBRARY(paramedloader ${paramedloader_SOURCES}) TARGET_LINK_LIBRARIES(paramedloader paramedmem medloader ${PLATFORM_LIBS}) INSTALL(TARGETS paramedloader EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${MEDCOUPLING_INSTALL_LIBS}) diff --git a/src/ParaMEDMEM/CMakeLists.txt b/src/ParaMEDMEM/CMakeLists.txt index 519e36776..dfa8c13a1 100644 --- a/src/ParaMEDMEM/CMakeLists.txt +++ b/src/ParaMEDMEM/CMakeLists.txt @@ -61,7 +61,7 @@ SET(paramedmem_SOURCES ExplicitMapping.cxx ) -ADD_LIBRARY(paramedmem SHARED ${paramedmem_SOURCES}) +ADD_LIBRARY(paramedmem ${paramedmem_SOURCES}) TARGET_LINK_LIBRARIES(paramedmem medcoupling ${MPI_LIBRARIES}) INSTALL(TARGETS paramedmem EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${MEDCOUPLING_INSTALL_LIBS}) diff --git a/src/ParaMEDMEMTest/CMakeLists.txt b/src/ParaMEDMEMTest/CMakeLists.txt index 789f24c04..0376fb2eb 100644 --- a/src/ParaMEDMEMTest/CMakeLists.txt +++ b/src/ParaMEDMEMTest/CMakeLists.txt @@ -66,7 +66,7 @@ SET(ParaMEDMEMTest_SOURCES test_MPI_Access_ISend_IRecv_BottleNeck.cxx ) -ADD_LIBRARY(ParaMEDMEMTest SHARED ${ParaMEDMEMTest_SOURCES}) +ADD_LIBRARY(ParaMEDMEMTest ${ParaMEDMEMTest_SOURCES}) SET_TARGET_PROPERTIES(ParaMEDMEMTest PROPERTIES COMPILE_FLAGS "") TARGET_LINK_LIBRARIES(ParaMEDMEMTest paramedmem paramedloader medcouplingremapper InterpKernelTestUtils ${CPPUNIT_LIBRARIES}) INSTALL(TARGETS ParaMEDMEMTest DESTINATION ${MEDCOUPLING_INSTALL_LIBS}) diff --git a/src/RENUMBER/CMakeLists.txt b/src/RENUMBER/CMakeLists.txt index 47a343470..d260bf274 100644 --- a/src/RENUMBER/CMakeLists.txt +++ b/src/RENUMBER/CMakeLists.txt @@ -88,7 +88,7 @@ SET_TARGET_PROPERTIES(renumber PROPERTIES COMPILE_FLAGS "${renumber_DEFINITIONS} TARGET_LINK_LIBRARIES(renumber renumbercpp) INSTALL(TARGETS renumber DESTINATION ${MEDCOUPLING_INSTALL_BINS}) -ADD_LIBRARY(renumbercpp SHARED ${renumbercpp_SOURCES}) +ADD_LIBRARY(renumbercpp ${renumbercpp_SOURCES}) SET_TARGET_PROPERTIES(renumbercpp PROPERTIES COMPILE_FLAGS "${renumber_DEFINITIONS}") TARGET_LINK_LIBRARIES(renumbercpp ${renumbercpp_LDFLAGS}) INSTALL(TARGETS renumbercpp DESTINATION ${MEDCOUPLING_INSTALL_LIBS})