Commit 37245477 authored by Ben Boeckel's avatar Ben Boeckel

cmake: remove support for dual static/shared builds

For building shared and static libraries, using two different build
trees is best rather than trying to hack up a single build to do
multiple things.
parent 0662941f
......@@ -16,22 +16,11 @@ set(XDMF_PATCH_VERSION 0)
set(XDMF_VERSION "${XDMF_MAJOR_VERSION}.${XDMF_MINOR_VERSION}.${XDMF_PATCH_VERSION}")
if(BUILD_SHARED_LIBS)
set(LIBTYPE SHARED)
set(BUILD_SHARED 1)
else()
set(LIBTYPE STATIC)
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/XdmfConfig.hpp.in
${CMAKE_CURRENT_BINARY_DIR}/XdmfConfig.hpp)
if (WIN32)
set(XDMF_STATIC_AND_SHARED OFF)
else()
option(XDMF_STATIC_AND_SHARED
"Build both static and shared libraries" ON)
mark_as_advanced(FORCE XDMF_STATIC_AND_SHARED)
endif()
# Enable CMake testing
option(XDMF_BUILD_TESTING "Build Tests" OFF)
if(XDMF_BUILD_TESTING)
......@@ -39,10 +28,6 @@ if(XDMF_BUILD_TESTING)
include(CTest)
endif()
if (XDMF_STATIC_AND_SHARED)
add_definitions(-DXDMFSTATIC)
endif ()
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
......@@ -347,26 +332,7 @@ if(NOT XDMF_BUILD_CORE_ONLY)
XdmfTopologyType
XdmfUnstructuredGrid)
if(XDMF_STATIC_AND_SHARED)
add_library(XdmfObjects OBJECT ${XdmfSources})
SET_TARGET_PROPERTIES(
XdmfObjects PROPERTIES
VERSION ${XDMF_VERSION}
SOVERSION ${XDMF_MAJOR_VERSION}
)
set_target_properties(XdmfObjects PROPERTIES
POSITION_INDEPENDENT_CODE True)
add_library(${XDMF_LIBNAME} $<TARGET_OBJECTS:XdmfObjects>)
if (BUILD_SHARED_LIBS)
add_library(Xdmf_Static STATIC $<TARGET_OBJECTS:XdmfObjects>)
set_target_properties(
Xdmf_Static PROPERTIES
OUTPUT_NAME "Xdmf"
)
endif (BUILD_SHARED_LIBS)
else()
add_library(${XDMF_LIBNAME} ${LIBTYPE} ${XdmfSources})
endif()
add_library(${XDMF_LIBNAME} ${XdmfSources})
SET_TARGET_PROPERTIES(
${XDMF_LIBNAME} PROPERTIES
VERSION ${XDMF_VERSION}
......@@ -374,14 +340,8 @@ if(NOT XDMF_BUILD_CORE_ONLY)
)
if(XDMF_BUILD_DSM)
target_link_libraries(${XDMF_LIBNAME} XdmfCore XdmfDSM)
if(XDMF_STATIC_AND_SHARED AND BUILD_SHARED_LIBS)
target_link_libraries(Xdmf_Static XdmfCore_Static XdmfDSM_Static)
endif()
else(XDMF_BUILD_DSM)
target_link_libraries(${XDMF_LIBNAME} XdmfCore)
if(XDMF_STATIC_AND_SHARED AND BUILD_SHARED_LIBS)
target_link_libraries(Xdmf_Static XdmfCore_Static)
endif ()
endif(XDMF_BUILD_DSM)
if (COMMAND vtk_target_install)
vtk_target_install(${XDMF_LIBNAME})
......@@ -391,10 +351,6 @@ if(NOT XDMF_BUILD_CORE_ONLY)
if (BUILD_SHARED_LIBS)
set_target_properties(${XDMF_LIBNAME} PROPERTIES
DEFINE_SYMBOL XDMF_EXPORTS)
if(XDMF_STATIC_AND_SHARED)
set_target_properties(Xdmf_Static PROPERTIES
DEFINE_SYMBOL Xdmf_EXPORTS)
endif()
endif ()
endif()
......@@ -457,12 +413,6 @@ if(NOT XDMF_BUILD_CORE_ONLY)
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
if (XDMF_STATIC_AND_SHARED AND BUILD_SHARED_LIBS)
install(TARGETS Xdmf_Static
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
endif()
if(WIN32 AND NOT CYGWIN)
......
......@@ -14,10 +14,7 @@ if(VERSION_CONTROL_AUTOUPDATE OR
endif()
if(BUILD_SHARED_LIBS)
set(LIBTYPE SHARED)
set(BUILD_SHARED 1)
else()
set(LIBTYPE STATIC)
endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
......@@ -192,28 +189,7 @@ set(XdmfCoreSources
core/XdmfWriter
PARENT_SCOPE)
if (XDMF_STATIC_AND_SHARED)
add_library(XdmfCoreObjects OBJECT ${XdmfCoreSources})
SET_TARGET_PROPERTIES(
XdmfCoreObjects PROPERTIES
VERSION ${XDMF_VERSION}
SOVERSION ${XDMF_MAJOR_VERSION}
)
set_target_properties(
XdmfCoreObjects PROPERTIES
POSITION_INDEPENDENT_CODE True
)
add_library(XdmfCore ${LIBTYPE} $<TARGET_OBJECTS:XdmfCoreObjects>)
if (BUILD_SHARED_LIBS)
add_library(XdmfCore_Static STATIC $<TARGET_OBJECTS:XdmfCoreObjects>)
set_target_properties(
XdmfCore_Static PROPERTIES
OUTPUT_NAME "XdmfCore"
)
endif (BUILD_SHARED_LIBS)
else()
add_library(XdmfCore ${LIBTYPE} ${XdmfCoreSources})
endif()
add_library(XdmfCore ${XdmfCoreSources})
SET_TARGET_PROPERTIES(
XdmfCore PROPERTIES
VERSION ${XDMF_VERSION}
......@@ -223,9 +199,6 @@ SET_TARGET_PROPERTIES(
link_directories(${XDMF_LIBRARY_DIRS})
target_link_libraries(XdmfCore ${XDMF_LIBRARIES})
if (XDMF_STATIC_AND_SHARED AND BUILD_SHARED_LIBS)
target_link_libraries(XdmfCore_Static ${XDMF_LIBRARIES})
endif()
if (COMMAND vtk_target_install)
vtk_target_install(XdmfCore)
......@@ -236,10 +209,6 @@ if(WIN32)
if (BUILD_SHARED_LIBS)
set_target_properties(XdmfCore PROPERTIES
DEFINE_SYMBOL XdmfCore_EXPORTS)
if (XDMF_STATIC_AND_SHARED)
set_target_properties(XdmfCore_Static PROPERTIES
DEFINE_SYMBOL XdmfCore_EXPORTS)
endif()
endif()
endif()
......@@ -292,12 +261,6 @@ install(TARGETS XdmfCore
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
if (XDMF_STATIC_AND_SHARED AND BUILD_SHARED_LIBS)
install(TARGETS XdmfCore_Static
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
endif ()
if (Boost_FOUND)
set(FOUND_BOOST_INCLUDES ${Boost_INCLUDE_DIRS})
......
......@@ -85,63 +85,25 @@ if (XDMF_DSM_IS_CRAY)
add_definitions(-DXDMF_DSM_IS_CRAY)
endif (XDMF_DSM_IS_CRAY)
add_library(XdmfDSMObjects OBJECT ${XdmfDSMSources})
SET_TARGET_PROPERTIES(
XdmfDSMObjects PROPERTIES
VERSION ${XDMF_VERSION}
SOVERSION ${XDMF_MAJOR_VERSION}
)
set_target_properties(XdmfDSMObjects PROPERTIES
POSITION_INDEPENDENT_CODE True)
add_library(XdmfDSM $<TARGET_OBJECTS:XdmfDSMObjects>)
add_library(XdmfDSM ${XdmfDSMSources})
SET_TARGET_PROPERTIES(
XdmfDSM PROPERTIES
VERSION ${XDMF_VERSION}
SOVERSION ${XDMF_MAJOR_VERSION}
)
if (BUILD_SHARED_LIBS)
add_library(XdmfDSM_Static STATIC $<TARGET_OBJECTS:XdmfDSMObjects>)
if (UNIX)
set_target_properties(XdmfDSM_Static PROPERTIES
OUTPUT_NAME "XdmfDSM")
endif (UNIX)
endif (BUILD_SHARED_LIBS)
#add_library(XdmfDSM ${XdmfDSMSources})
#if (BUILD_SHARED_LIBS)
# add_library(XdmfDSM_Static STATIC ${XdmfDSMSources})
# if (UNIX)
# set_target_properties(XdmfDSM_Static PROPERTIES
# OUTPUT_NAME "XdmfDSM")
# endif (UNIX)
#endif (BUILD_SHARED_LIBS)
link_directories(${XDMF_LIBRARY_DIRS} ${XdmfDSMLinkLibraryDir})
target_link_libraries(XdmfDSM ${XdmfDSMLinkLibraries})
if (BUILD_SHARED_LIBS)
target_link_libraries(XdmfDSM_Static ${XdmfDSMLinkLibraries})
endif (BUILD_SHARED_LIBS)
if(WIN32)
add_definitions(-D_HDF5USEDLL_ -D_HDF5USEHLDLL_)
set_target_properties(XdmfDSM PROPERTIES
DEFINE_SYMBOL XdmfDSM_EXPORTS)
if (BUILD_SHARED_LIBS)
set_target_properties(XdmfDSM_Static PROPERTIES
DEFINE_SYMBOL XdmfDSM_EXPORTS)
endif (BUILD_SHARED_LIBS)
set_target_properties(XdmfDSM PROPERTIES
PREFIX ../
IMPORT_PREFIX ../
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
if (BUILD_SHARED_LIBS)
set_target_properties(XdmfDSM_Static PROPERTIES
PREFIX ../
IMPORT_PREFIX ../
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
endif()
endif()
if(XDMF_WRAP_JAVA)
......@@ -187,12 +149,6 @@ install(TARGETS XdmfDSM
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
if (BUILD_SHARED_LIBS)
install(TARGETS XdmfDSM_Static
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
endif (BUILD_SHARED_LIBS)
if(XDMF_BUILD_DSM_THREADS)
set(XdmfDSM_INCLUDE_DIRS
......
......@@ -92,26 +92,7 @@ if(XDMF_BUILD_PARTITIONER)
set(XdmfUtilsLinkLibraries ${XdmfUtilsLinkLibraries} ${METIS_LIBRARIES})
endif(XDMF_BUILD_PARTITIONER)
if (XDMF_STATIC_AND_SHARED)
add_library(XdmfUtilsObjects OBJECT ${XdmfUtilsSources})
SET_TARGET_PROPERTIES(
XdmfUtilsObjects PROPERTIES
VERSION ${XDMF_VERSION}
SOVERSION ${XDMF_MAJOR_VERSION}
)
set_target_properties(XdmfUtilsObjects PROPERTIES
POSITION_INDEPENDENT_CODE True)
add_library(XdmfUtils $<TARGET_OBJECTS:XdmfUtilsObjects>)
if (BUILD_SHARED_LIBS)
add_library(XdmfUtils_Static STATIC $<TARGET_OBJECTS:XdmfUtilsObjects>)
if (UNIX)
set_target_properties(XdmfUtils_Static PROPERTIES
OUTPUT_NAME "XdmfUtils")
endif (UNIX)
endif (BUILD_SHARED_LIBS)
else ()
add_library(XdmfUtils ${XdmfUtilsSources})
endif ()
add_library(XdmfUtils ${XdmfUtilsSources})
SET_TARGET_PROPERTIES(
XdmfUtils PROPERTIES
VERSION ${XDMF_VERSION}
......@@ -119,9 +100,6 @@ SET_TARGET_PROPERTIES(
)
target_link_libraries(XdmfUtils ${XdmfUtilsLinkLibraries})
if (BUILD_SHARED_LIBS)
target_link_libraries(XdmfUtils_Static ${XdmfUtilsLinkLibraries})
endif (BUILD_SHARED_LIBS)
if(WIN32)
set_target_properties(${executable} PROPERTIES
......@@ -181,12 +159,6 @@ install(TARGETS XdmfUtils
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
if (BUILD_SHARED_LIBS)
install(TARGETS XdmfUtils_Static
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
endif (BUILD_SHARED_LIBS)
install(TARGETS ${XdmfUtilsExecutables}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment