diff --git a/CMakeLists.txt b/CMakeLists.txt index b1c1993..cdcba63 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,14 +1,25 @@ -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) -set(COLLADA14_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include/1.4) -set(COLLADA15_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include/1.5) +project(colladadom) +cmake_minimum_required(VERSION 3.17) + +include(FindPkgConfig) + +find_package(Boost REQUIRED CONFIG) +pkg_check_modules(LIBXML2 libxml-2.0) +pkg_check_modules(MINIZIP minizip) +pkg_check_modules(ZLIB zlib) + +set(COLLADA_DOM_SOVERSION "0") +set(COLLADA_DOM_VERSION "2.3") + file(GLOB dae_files ${CMAKE_CURRENT_SOURCE_DIR}/src/dae/*.cpp) file(GLOB libxmlplugin_files ${CMAKE_CURRENT_SOURCE_DIR}/src/modules/LIBXMLPlugin/*.cpp) file(GLOB stddatabase_files ${CMAKE_CURRENT_SOURCE_DIR}/src/modules/STLDatabase/*.cpp) file(GLOB stderrplugin_files ${CMAKE_CURRENT_SOURCE_DIR}/src/modules/stdErrPlugin/*.cpp) set(COLLADA_BASE_SOURCES ${dae_files} ${libxmlplugin_files} ${stddatabase_files} ${stderrplugin_files}) -set(COLLADA_LIBS minizip ${ZLIB_LIBRARIES} ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY}) -set(COLLADA_COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS} ${Boost_CFLAGS} -DDOM_INCLUDE_LIBXML") +set(COLLADA_LIBS ${LIBXML2_LIBRARIES} ${MINIZIP_LIBRARIES} ${ZLIB_LIBRARIES} ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_REGEX_LIBRARY}) +list(JOIN MINIZIP_CFLAGS " " VAR_MINIZIP_CFLAGS) +set(COLLADA_COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS} ${VAR_MINIZIP_CFLAGS} ${Boost_CFLAGS} -DDOM_INCLUDE_LIBXML") if( OPT_COLLADA15 ) add_subdirectory(src/1.5) @@ -17,8 +28,8 @@ if( OPT_COLLADA14 ) add_subdirectory(src/1.4) endif() -install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/1.4 DESTINATION ${COLLADA_DOM_INCLUDE_INSTALL_DIR} PATTERN ".svn" EXCLUDE PATTERN ".~" EXCLUDE) -install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/1.5 DESTINATION ${COLLADA_DOM_INCLUDE_INSTALL_DIR} PATTERN ".svn" EXCLUDE PATTERN ".~" EXCLUDE) -install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/dae DESTINATION ${COLLADA_DOM_INCLUDE_INSTALL_DIR} PATTERN ".svn" EXCLUDE PATTERN ".~" EXCLUDE) -install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/modules DESTINATION ${COLLADA_DOM_INCLUDE_INSTALL_DIR} PATTERN ".svn" EXCLUDE PATTERN ".~" EXCLUDE) -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/dae.h ${CMAKE_CURRENT_SOURCE_DIR}/include/dae.h DESTINATION ${COLLADA_DOM_INCLUDE_INSTALL_DIR}) +# install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/1.4 DESTINATION ${COLLADA_DOM_INCLUDE_INSTALL_DIR} PATTERN ".svn" EXCLUDE PATTERN ".~" EXCLUDE) +# install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/1.5 DESTINATION ${COLLADA_DOM_INCLUDE_INSTALL_DIR} PATTERN ".svn" EXCLUDE PATTERN ".~" EXCLUDE) +# install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/dae DESTINATION ${COLLADA_DOM_INCLUDE_INSTALL_DIR} PATTERN ".svn" EXCLUDE PATTERN ".~" EXCLUDE) +# install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/modules DESTINATION ${COLLADA_DOM_INCLUDE_INSTALL_DIR} PATTERN ".svn" EXCLUDE PATTERN ".~" EXCLUDE) +# install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/dae.h ${CMAKE_CURRENT_SOURCE_DIR}/include/dae.h DESTINATION ${COLLADA_DOM_INCLUDE_INSTALL_DIR}) diff --git a/src/1.4/CMakeLists.txt b/src/1.4/CMakeLists.txt index 17fbaea..93b8256 100644 --- a/src/1.4/CMakeLists.txt +++ b/src/1.4/CMakeLists.txt @@ -1,10 +1,26 @@ file(GLOB dom_files ${CMAKE_CURRENT_SOURCE_DIR}/dom/*.cpp) -include_directories(${COLLADA14_INCLUDE_DIR}) -add_library(collada14dom SHARED ${COLLADA_BASE_SOURCES} ${dom_files}) +add_library(collada14dom STATIC ${COLLADA_BASE_SOURCES} ${dom_files}) +target_compile_options(collada14dom PRIVATE + "-Wno-error=unused-result" "-Wno-cast-user-defined" "-Wno-nonnull" +) +target_include_directories(collada14dom PRIVATE + ${colladadom_SOURCE_DIR}/include + ${colladadom_SOURCE_DIR}/include/1.4 + ${Boost_INCLUDE_DIRS} + ${LIBXML2_INCLUDE_DIRS} + ${MINIZIP_INCLUDE_DIRS} + ${ZLIB_INCLUDE_DIRS} +) +target_link_directories(collada14dom INTERFACE + ${Boost_LIBRARY_DIRS} + ${LIBXML2_LIBRARY_DIRS} + ${MINIZIP_LIBRARY_DIRS} + ${ZLIB_LIBRARY_DIRS} +) target_link_libraries(collada14dom ${COLLADA_LIBS}) set_target_properties(collada14dom PROPERTIES COMPILE_FLAGS "${COLLADA_COMPILE_FLAGS}" CLEAN_DIRECT_OUTPUT 1 SOVERSION ${COLLADA_DOM_SOVERSION} VERSION ${COLLADA_DOM_VERSION}) -install(TARGETS collada14dom DESTINATION lib${LIB_SUFFIX}) +# install(TARGETS collada14dom DESTINATION ${COLLADA_DOM_LIBS_INSTALL_DIR}) diff --git a/src/1.5/CMakeLists.txt b/src/1.5/CMakeLists.txt index e061a01..fb73a70 100644 --- a/src/1.5/CMakeLists.txt +++ b/src/1.5/CMakeLists.txt @@ -1,10 +1,10 @@ file(GLOB dom_files ${CMAKE_CURRENT_SOURCE_DIR}/dom/*.cpp) include_directories(${COLLADA15_INCLUDE_DIR}) -add_library(collada15dom SHARED ${COLLADA_BASE_SOURCES} ${dom_files}) +add_library(collada15dom STATIC ${COLLADA_BASE_SOURCES} ${dom_files}) target_link_libraries(collada15dom ${COLLADA_LIBS}) set_target_properties(collada15dom PROPERTIES COMPILE_FLAGS "${COLLADA_COMPILE_FLAGS}" CLEAN_DIRECT_OUTPUT 1 SOVERSION ${COLLADA_DOM_SOVERSION} VERSION ${COLLADA_DOM_VERSION}) -install(TARGETS collada15dom DESTINATION lib${LIB_SUFFIX}) +install(TARGETS collada15dom DESTINATION ${COLLADA_DOM_LIBS_INSTALL_DIR}) diff --git a/src/dae/daeUtils.cpp b/src/dae/daeUtils.cpp index 682692c..0e61ef1 100644 --- a/src/dae/daeUtils.cpp +++ b/src/dae/daeUtils.cpp @@ -118,7 +118,7 @@ list cdom::makeStringList(const char* s, ...) { va_end(args); return result; } -#endif 0 +#endif // 0 string cdom::getCurrentDir() { #ifdef __CELLOS_LV2__ @@ -154,7 +154,7 @@ char cdom::getFileSeparator() { const string& cdom::getSystemTmpDir() { #ifdef WIN32 static string tmpDir = string(getenv("TMP")) + getFileSeparator(); -#elif defined(__linux__) || defined(__linux) +#elif defined(__linux__) || defined(__linux) || defined(__FreeBSD__) static string tmpDir = "/tmp/"; #elif defined __APPLE_CC__ static string tmpDir = string(getenv("TMPDIR")); @@ -173,7 +173,7 @@ string cdom::getRandomFileName() { std::string tmp(tmpnam(&tmpbuffer[0])); #ifdef WIN32 randomSegment = tmp.substr(tmp.find_last_of('\\')+1); -#elif defined(__linux__) || defined(__linux) +#elif defined(__linux__) || defined(__linux) || defined(__FreeBSD__) randomSegment = tmp.substr(tmp.find_last_of('/')+1); #elif defined __APPLE_CC__ randomSegment = tmp.substr(tmp.find_last_of('/')+1);