Warning, /DD4hep/DDCAD/CMakeLists.txt is written in an unsupported language. File is not indexed.
0001 #==========================================================================
0002 # AIDA Detector description implementation
0003 #--------------------------------------------------------------------------
0004 # Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 # All rights reserved.
0006 #
0007 # For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 # For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 #
0010 #==========================================================================
0011 SET_PROPERTY(DIRECTORY . PROPERTY PACKAGE_NAME DDCAD)
0012 #
0013 if(${ROOT_VERSION} VERSION_LESS 6.21.01)
0014 return()
0015 endif()
0016 #
0017 # Open Asset Importer Library
0018 #
0019 find_package(assimp QUIET)
0020 if(TARGET assimp::assimp)
0021 MESSAGE(STATUS "+++> Use existing assimp implementation")
0022 elseif(DD4HEP_LOAD_ASSIMP)
0023 MESSAGE(STATUS "+++> Download and build assimp from gitub")
0024 #
0025 # Download The Open-Asset-Importer-Lib from GITHUB
0026 #
0027 include(ExternalProject)
0028 find_package(Git REQUIRED)
0029 set(ASSIMP_C_FLAGS "")
0030 set(ASSIMP_CXX_FLAGS "-Wno-class-memaccess -Wno-tautological-compare -Wno-sizeof-pointer-memaccess")
0031
0032 if( "${CMAKE_BUILD_TYPE}" STREQUAL "Debug" )
0033 set(ASSIMP_BYPRODUCT "${INSTALL_DIR}/lib/libassimpd${CMAKE_SHARED_LIBRARY_SUFFIX}")
0034 else()
0035 set(ASSIMP_BYPRODUCT "${INSTALL_DIR}/lib/libassimp${CMAKE_SHARED_LIBRARY_SUFFIX}")
0036 endif()
0037
0038 ExternalProject_Add(
0039 assimp_project
0040 SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/external/assimp
0041 INSTALL_DIR ${CMAKE_INSTALL_PREFIX}
0042 GIT_REPOSITORY https://github.com/assimp/assimp.git
0043 GIT_TAG v5.0.1
0044 CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
0045 -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}
0046 -DCMAKE_CXX_FLAGS=${ASSIMP_CXX_FLAGS}
0047 -DCMAKE_C_FLAGS=${ASSIMP_C_FLAGS}
0048 -DCMAKE_SHARED_LINKER_FLAGS=${CMAKE_SHARED_LINKER_FLAGS}
0049 -DBUILD_SHARED_LIBS=1
0050 -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
0051 BUILD_COMMAND ${CMAKE_BUILD_TOOL} install
0052 INSTALL_COMMAND ""
0053 BUILD_BYPRODUCTS ${ASSIMP_BYPRODUCT}
0054 )
0055 ExternalProject_Get_Property(assimp_project INSTALL_DIR)
0056 set(ASSIMP_INCLUDE_DIRS "${INSTALL_DIR}/include")
0057 EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E make_directory ${ASSIMP_INCLUDE_DIRS})
0058
0059 add_library(assimp SHARED IMPORTED GLOBAL)
0060 add_dependencies(assimp assimp_project)
0061 add_library(assimp::assimp ALIAS assimp)
0062 set_target_properties(assimp PROPERTIES IMPORTED_LOCATION ${ASSIMP_BYPRODUCT})
0063 target_include_directories(assimp INTERFACE ${ASSIMP_INCLUDE_DIRS})
0064 else()
0065 MESSAGE(STATUS "+++> No ASSIMP implementation accessible. CAD reading will not be supported!")
0066 return()
0067 endif()
0068 #
0069 MESSAGE(STATUS "Open-Asset-Importer: ASSIMP_INCLUDE_DIRS: ${ASSIMP_INCLUDE_DIRS}")
0070 MESSAGE(STATUS "Open-Asset-Importer: ASSIMP_LIBRARIES: ${ASSIMP_LIBRARIES}")
0071 #
0072 # For the rest: ensure assimp is built before starting to compile.....
0073 #
0074 dd4hep_add_dictionary(G__DDCAD
0075 SOURCES ../DDCore/include/ROOT/Warnings.h src/CADDictionary.h
0076 LINKDEF ../DDCore/include/ROOT/LinkDef.h
0077 USES DD4hep::DDCore DD4hep::DDParsers assimp::assimp
0078 )
0079
0080 file(GLOB DDCAD_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)
0081 add_library(DDCAD ${DDCAD_SOURCES} G__DDCAD.cxx)
0082 add_library(DD4hep::DDCAD ALIAS DDCAD)
0083 # IF(TARGET assimp_project)
0084 # MESSAGE(STATUS "have to build assimp first")
0085 # add_dependencies(G__DDCAD assimp_project)
0086 # add_dependencies(DDCAD assimp_project)
0087 # ENDIF()
0088
0089 if(TARGET assimp::assimp)
0090 MESSAGE(STATUS "have target assimp::assimp")
0091 endif()
0092
0093 target_include_directories(DDCAD
0094 PUBLIC
0095 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>
0096 $<INSTALL_INTERFACE:include>
0097 )
0098 target_link_libraries(DDCAD PUBLIC DD4hep::DDCore assimp::assimp ROOT::RCsg)
0099
0100 dd4hep_add_plugin(DDCADPlugins
0101 SOURCES src/plugins/*.cpp
0102 USES DD4hep::DDCore DD4hep::DDCAD
0103 )
0104
0105 set_target_properties(DDCAD DDCADPlugins PROPERTIES VERSION ${DD4hep_VERSION} SOVERSION ${DD4hep_SOVERSION})
0106
0107 install(DIRECTORY include/DDCAD DESTINATION include)
0108 install(TARGETS DDCAD DDCADPlugins EXPORT DD4hep
0109 LIBRARY DESTINATION lib
0110 ARCHIVE DESTINATION lib)