Skip to content

Commit

Permalink
publish
Browse files Browse the repository at this point in the history
  • Loading branch information
WJsjtu committed Mar 21, 2022
1 parent d0c79c4 commit 9ff4236
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 59 deletions.
76 changes: 20 additions & 56 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,61 +82,31 @@ target_link_libraries(${LIBRARY_NAME} "ext-mikktspace")
if(WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4819")
if(USE_IMAGE_SHARED)
if ("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32")
target_include_directories(${LIBRARY_NAME} PRIVATE "${CMAKE_BINARY_DIR}/download/ImageDecoder/win32/x86/shared/$<IF:$<CONFIG:Debug>,Debug,MinSizeRel>/include")
target_link_libraries(${LIBRARY_NAME} "${CMAKE_BINARY_DIR}/download/ImageDecoder/win32/x86/shared/$<IF:$<CONFIG:Debug>,Debug,MinSizeRel>/lib/image.lib")
else()
target_include_directories(${LIBRARY_NAME} PRIVATE "${CMAKE_BINARY_DIR}/download/ImageDecoder/win32/x64/shared/$<IF:$<CONFIG:Debug>,Debug,MinSizeRel>/include")
target_link_libraries(${LIBRARY_NAME} "${CMAKE_BINARY_DIR}/download/ImageDecoder/win32/x64/shared/$<IF:$<CONFIG:Debug>,Debug,MinSizeRel>/lib/image.lib")
endif()
target_include_directories(${LIBRARY_NAME} PRIVATE "${IMAGE_DECODER_INSTALL_DIR}/include")
target_link_libraries(${LIBRARY_NAME} "${IMAGE_DECODER_INSTALL_DIR}/lib/image.lib")
else()
target_compile_definitions(${LIBRARY_NAME} PRIVATE IMAGE_STATIC)
if ("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32")
file(
GLOB_RECURSE image_debug_libs
LIST_DIRECTORIES false
"${CMAKE_BINARY_DIR}/download/ImageDecoder/win32/x86/static/Debug/lib/*.lib"
)
file(
GLOB_RECURSE image_release_libs
LIST_DIRECTORIES false
"${CMAKE_BINARY_DIR}/download/ImageDecoder/win32/x86/static/MinSizeRel/lib/*.lib"
)
target_include_directories(${LIBRARY_NAME} PRIVATE "${CMAKE_BINARY_DIR}/download/ImageDecoder/win32/x86/static/$<IF:$<CONFIG:Debug>,Debug,MinSizeRel>/include")
target_link_libraries(${LIBRARY_NAME} "$<IF:$<CONFIG:Debug>,${image_debug_libs},${image_release_libs}>")
else()
file(
GLOB_RECURSE image_debug_libs
LIST_DIRECTORIES false
"${CMAKE_BINARY_DIR}/download/ImageDecoder/win32/x64/static/Debug/lib/*.lib"
)
file(
GLOB_RECURSE image_release_libs
LIST_DIRECTORIES false
"${CMAKE_BINARY_DIR}/download/ImageDecoder/win32/x64/static/MinSizeRel/lib/*.lib"
)
target_include_directories(${LIBRARY_NAME} PRIVATE "${CMAKE_BINARY_DIR}/download/ImageDecoder/win32/x64/static/$<IF:$<CONFIG:Debug>,Debug,MinSizeRel>/include")
target_link_libraries(${LIBRARY_NAME} "$<IF:$<CONFIG:Debug>,${image_debug_libs},${image_release_libs}>")
endif()
file(
GLOB_RECURSE image_libs
LIST_DIRECTORIES false
"${IMAGE_DECODER_INSTALL_DIR}/lib/*.lib"
)
target_include_directories(${LIBRARY_NAME} PRIVATE "${IMAGE_DECODER_INSTALL_DIR}/include")
target_link_libraries(${LIBRARY_NAME} "${image_libs}")
endif()
else()
if(USE_IMAGE_SHARED)
target_include_directories(${LIBRARY_NAME} PRIVATE "${CMAKE_BINARY_DIR}/download/ImageDecoder/darwin/shared/$<IF:$<CONFIG:Debug>,Debug,MinSizeRel>/include")
target_link_libraries(${LIBRARY_NAME} "${CMAKE_BINARY_DIR}/download/ImageDecoder/darwin/shared/$<IF:$<CONFIG:Debug>,Debug,MinSizeRel>/lib/libimage.dylib")
target_include_directories(${LIBRARY_NAME} PRIVATE "${IMAGE_DECODER_INSTALL_DIR}/include")
target_link_libraries(${LIBRARY_NAME} "${IMAGE_DECODER_INSTALL_DIR}/bin/libimage.dylib")
else()
target_compile_definitions(${LIBRARY_NAME} PRIVATE IMAGE_STATIC)
file(
GLOB_RECURSE image_debug_libs
LIST_DIRECTORIES false
"${CMAKE_BINARY_DIR}/download/ImageDecoder/darwin/static/Debug/lib/*.a"
)
file(
GLOB_RECURSE image_release_libs
GLOB_RECURSE image_libs
LIST_DIRECTORIES false
"${CMAKE_BINARY_DIR}/download/ImageDecoder/darwin/static/MinSizeRel/lib/*.a"
"${IMAGE_DECODER_INSTALL_DIR}/lib/*.a"
)
target_include_directories(${LIBRARY_NAME} PRIVATE "${CMAKE_BINARY_DIR}/download/ImageDecoder/darwin/static/$<IF:$<CONFIG:Debug>,Debug,MinSizeRel>/include")
target_link_libraries(${LIBRARY_NAME} "$<IF:$<CONFIG:Debug>,${image_debug_libs},${image_release_libs}>")
target_include_directories(${LIBRARY_NAME} PRIVATE "${IMAGE_DECODER_INSTALL_DIR}/include")
target_link_libraries(${LIBRARY_NAME} "${image_libs}")
endif()

target_compile_options(${LIBRARY_NAME} PUBLIC -fvisibility=hidden)
Expand All @@ -158,7 +128,7 @@ endif()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR})
find_package(Fbx 2020.2.1)
if(NOT FBX_FOUND)
message("Fbx SDK not found!")
message("Fbx SDK not found!")
else()
target_include_directories(${LIBRARY_NAME} PUBLIC ${FBX_INCLUDE_DIRS})
target_link_libraries(${LIBRARY_NAME} debug ${FBX_LIBRARIES_DEBUG} optimized ${FBX_LIBRARIES})
Expand Down Expand Up @@ -225,23 +195,17 @@ add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD

if(WIN32)
if(USE_IMAGE_SHARED)
if ("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32")
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_BINARY_DIR}/download/ImageDecoder/win32/x86/shared/$<IF:$<CONFIG:Debug>,Debug,MinSizeRel>/bin" "$<TARGET_FILE_DIR:${PROJECT_NAME}>"
)
else()
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_BINARY_DIR}/download/ImageDecoder/win32/x64/shared/$<IF:$<CONFIG:Debug>,Debug,MinSizeRel>/bin" "$<TARGET_FILE_DIR:${PROJECT_NAME}>"
)
endif()
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory "${IMAGE_DECODER_INSTALL_DIR}/bin" "$<TARGET_FILE_DIR:${PROJECT_NAME}>"
)
endif()
else()
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-Wl,-rpath,./")
set_target_properties(${PROJECT_NAME} PROPERTIES CMAKE_BUILD_RPATH "$ORIGIN")
set_target_properties(${PROJECT_NAME} PROPERTIES CMAKE_INSTALL_RPATH "$ORIGIN")
if(USE_IMAGE_SHARED)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_BINARY_DIR}/download/ImageDecoder/darwin/shared/$<IF:$<CONFIG:Debug>,Debug,MinSizeRel>/lib" "$<TARGET_FILE_DIR:${PROJECT_NAME}>"
COMMAND ${CMAKE_COMMAND} -E copy_directory "${IMAGE_DECODER_INSTALL_DIR}/bin" "$<TARGET_FILE_DIR:${PROJECT_NAME}>"
)
endif()
endif()
46 changes: 43 additions & 3 deletions ThirdParty/image.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,46 @@
UpdateExternalLib("ImageDecoder" https://github.com/WJsjtu/ImageDecoder.git "v0.0.1")

file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/download/ImageDecoder)
execute_process(COMMAND curl -L -o ${CMAKE_BINARY_DIR}/download/ImageDecoder/release.zip https://github.com/WJsjtu/ImageDecoder/releases/download/v0.0.1/release.zip)
set(IMAGE_DECODER_INSTALL_DIR "${CMAKE_BINARY_DIR}/ThirdParty/install/${CMAKE_BUILD_TYPE}/ImageDecoder")
set(IMAGE_DECODER_SOURCE_DIR "${PROJECT_SOURCE_DIR}/ThirdParty/ImageDecoder")

file(ARCHIVE_EXTRACT INPUT ${CMAKE_BINARY_DIR}/download/ImageDecoder/release.zip DESTINATION ${CMAKE_BINARY_DIR}/download/ImageDecoder VERBOSE)
if(WIN32)
execute_process(COMMAND ${CMAKE_COMMAND}
-G "${CMAKE_GENERATOR}"
-A "${CMAKE_GENERATOR_PLATFORM}"
-T "${CMAKE_GENERATOR_TOOLSET}"
-DCMAKE_CXX_FLAGS_RELEASE="/MD"
-DCMAKE_CXX_FLAGS_DEBUG="/MDd"
-DCMAKE_C_FLAGS_RELEASE="/MD"
-DCMAKE_C_FLAGS_DEBUG="/MDd"
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX=${IMAGE_DECODER_INSTALL_DIR}
-DBUILD_SHARED_LIBS=${USE_IMAGE_SHARED}
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
-B "${CMAKE_BINARY_DIR}/ThirdParty/build/${CMAKE_BUILD_TYPE}/ImageDecoder"
WORKING_DIRECTORY "${IMAGE_DECODER_SOURCE_DIR}"
)
execute_process(COMMAND ${CMAKE_COMMAND} --build . --config ${CMAKE_BUILD_TYPE} --target install
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/ThirdParty/build/${CMAKE_BUILD_TYPE}/ImageDecoder"
)
else()
execute_process(COMMAND ${CMAKE_COMMAND}
-G "${CMAKE_GENERATOR}"
-A "${CMAKE_GENERATOR_PLATFORM}"
-T "${CMAKE_GENERATOR_TOOLSET}"
-DCMAKE_MACOSX_RPATH=ON
-DCMAKE_OSX_DEPLOYMENT_TARGET="${OSX_VERSION}"
-DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX=${IMAGE_DECODER_INSTALL_DIR}
-DBUILD_SHARED_LIBS=${USE_IMAGE_SHARED}
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
-B "${CMAKE_BINARY_DIR}/ThirdParty/build/${CMAKE_BUILD_TYPE}/ImageDecoder"
WORKING_DIRECTORY "${IMAGE_DECODER_SOURCE_DIR}"
)
execute_process(COMMAND ${CMAKE_COMMAND} --build . --config ${CMAKE_BUILD_TYPE} --target install
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/ThirdParty/build/${CMAKE_BUILD_TYPE}/ImageDecoder"
)
endif()

set(IMAGE_DECODER_INSTALL_DIR "${IMAGE_DECODER_INSTALL_DIR}" CACHE PATH "zlib dir" FORCE)
set(IMAGE_DECODER_ROOT "${IMAGE_DECODER_SOURCE_DIR}" CACHE PATH "image decoder root" FORCE)

0 comments on commit 9ff4236

Please sign in to comment.