Skip to content

Commit

Permalink
Add option to build DXTex as shared lib to cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
bmarques1995 committed Jan 29, 2025
1 parent 9303898 commit cbba82d
Show file tree
Hide file tree
Showing 2 changed files with 151 additions and 134 deletions.
16 changes: 15 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ project (DirectXTex

option(BUILD_TOOLS "Build tex command-line tools" ON)

option(BUILD_SHARED_LIBS "Build DirectXTex as a shared library" OFF)

option(BUILD_SAMPLE "Build DDSView sample (requires fxc.exe)" ON)

# Includes the functions for Direct3D 11 resources and DirectCompute compression
Expand Down Expand Up @@ -220,7 +222,19 @@ if(BUILD_DX11 AND WIN32 AND (NOT (XBOX_CONSOLE_TARGET STREQUAL "durango")))
endif()
endif()

add_library(${PROJECT_NAME} STATIC ${LIBRARY_SOURCES} ${LIBRARY_HEADERS})
set(BUILD_TYPE STATIC)
if(BUILD_SHARED_LIBS)
set(BUILD_TYPE SHARED)
endif()

add_library(${PROJECT_NAME} ${BUILD_TYPE} ${LIBRARY_SOURCES} ${LIBRARY_HEADERS})

if(WIN32 AND BUILD_SHARED_LIBS)
target_compile_definitions(${PROJECT_NAME} PRIVATE DXTEX_API=__declspec\(dllexport\))
target_compile_definitions(${PROJECT_NAME} INTERFACE DXTEX_API=__declspec\(dllimport\))
else()
target_compile_definitions(${TARGET_NAME} PUBLIC DXTEX_API)
endif()

if(BUILD_DX11 AND WIN32)
target_include_directories(${PROJECT_NAME} PRIVATE ${COMPILED_SHADERS})
Expand Down
Loading

0 comments on commit cbba82d

Please sign in to comment.