Skip to content

Commit 518d50d

Browse files
committed
Fixes for Windows/MSYS2
1 parent 75ab2be commit 518d50d

File tree

6 files changed

+34
-28
lines changed

6 files changed

+34
-28
lines changed

CMakeLists.txt

+14-16
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,6 @@ IF (WIN32)
139139
ADD_DEFINITIONS( -DWIN32_LEAN_AND_MEAN )
140140

141141
IF(MSVC)
142-
OPTION (ASSIMP_BUILD_ASSIMP_VIEW
143-
"If the Assimp view tool is built. (requires DirectX)"
144-
OFF )
145-
146142
OPTION( ASSIMP_INSTALL_PDB
147143
"Install MSVC debug files."
148144
ON )
@@ -184,6 +180,7 @@ ENDIF()
184180
IF(NOT BUILD_SHARED_LIBS)
185181
MESSAGE(STATUS "Shared libraries disabled")
186182
SET(LINK_SEARCH_START_STATIC TRUE)
183+
SET(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX} ${CMAKE_FIND_LIBRARY_SUFFIXES})
187184
ELSE()
188185
MESSAGE(STATUS "Shared libraries enabled")
189186
ENDIF()
@@ -231,16 +228,6 @@ IF(ASSIMP_DOUBLE_PRECISION)
231228
ADD_DEFINITIONS(-DASSIMP_DOUBLE_PRECISION)
232229
ENDIF()
233230

234-
CONFIGURE_FILE(
235-
${CMAKE_CURRENT_LIST_DIR}/revision.h.in
236-
${CMAKE_CURRENT_BINARY_DIR}/revision.h
237-
)
238-
239-
CONFIGURE_FILE(
240-
${CMAKE_CURRENT_LIST_DIR}/include/assimp/config.h.in
241-
${CMAKE_CURRENT_BINARY_DIR}/include/assimp/config.h
242-
)
243-
244231
INCLUDE_DIRECTORIES( BEFORE
245232
./
246233
code/
@@ -710,7 +697,8 @@ ADD_SUBDIRECTORY( code/ )
710697
IF ( ASSIMP_BUILD_ASSIMP_TOOLS )
711698
# The viewer for windows only
712699
IF (WIN32)
713-
OPTION ( ASSIMP_BUILD_ASSIMP_VIEW "If the Assimp view tool is built. (requires DirectX)" OFF )
700+
FIND_PACKAGE(DirectX)
701+
OPTION ( ASSIMP_BUILD_ASSIMP_VIEW "If the Assimp view tool is built. (requires DirectX)" ${DirectX_FOUND} )
714702
IF ( ASSIMP_BUILD_ASSIMP_VIEW )
715703
ADD_SUBDIRECTORY( tools/assimp_view/ )
716704
ENDIF ()
@@ -735,12 +723,22 @@ IF ( ASSIMP_BUILD_TESTS )
735723
ADD_SUBDIRECTORY( test/ )
736724
ENDIF ()
737725

738-
# Generate a pkg-config .pc for the Assimp library.
726+
# Generate a pkg-config .pc, revision.h, and config.h for the Assimp library.
739727
CONFIGURE_FILE( "${PROJECT_SOURCE_DIR}/assimp.pc.in" "${PROJECT_BINARY_DIR}/assimp.pc" @ONLY )
740728
IF ( ASSIMP_INSTALL )
741729
INSTALL( FILES "${PROJECT_BINARY_DIR}/assimp.pc" DESTINATION ${ASSIMP_LIB_INSTALL_DIR}/pkgconfig/ COMPONENT ${LIBASSIMP-DEV_COMPONENT})
742730
ENDIF()
743731

732+
CONFIGURE_FILE(
733+
${CMAKE_CURRENT_LIST_DIR}/revision.h.in
734+
${CMAKE_CURRENT_BINARY_DIR}/revision.h
735+
)
736+
737+
CONFIGURE_FILE(
738+
${CMAKE_CURRENT_LIST_DIR}/include/assimp/config.h.in
739+
${CMAKE_CURRENT_BINARY_DIR}/include/assimp/config.h
740+
)
741+
744742
IF ( ASSIMP_INSTALL )
745743
IF(CMAKE_CPACK_COMMAND AND UNIX AND ASSIMP_OPT_BUILD_PACKAGES)
746744
# Packing information

cmake-modules/FindDirectX.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ if(WIN32) # The only platform it makes sense to check for DirectX SDK
5555
endif(CMAKE_CL_64)
5656
find_library(DirectX_LIBRARY NAMES d3d9 HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX})
5757
find_library(DirectX_D3DX9_LIBRARY NAMES d3dx9 HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX})
58-
find_library(DirectX_DXERR_LIBRARY NAMES DxErr HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX})
58+
find_library(DirectX_DXERR_LIBRARY NAMES DxErr DxErr9 HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX})
5959
find_library(DirectX_DXGUID_LIBRARY NAMES dxguid HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX})
6060

6161

code/CMakeLists.txt

+14-5
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,9 @@ ENDIF()
10531053
# Check dependencies for glTF importer with Open3DGC-compression.
10541054
# RT-extensions is used in "contrib/Open3DGC/o3dgcTimer.h" for collecting statistics. Pointed file
10551055
# has implementation for different platforms: WIN32, __MACH__ and other ("else" block).
1056-
FIND_PACKAGE(RT QUIET)
1056+
IF (NOT WIN32)
1057+
FIND_PACKAGE(RT QUIET)
1058+
ENDIF ()
10571059
IF (NOT ASSIMP_HUNTER_ENABLED AND (RT_FOUND OR WIN32))
10581060
SET( ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC 1 )
10591061
ADD_DEFINITIONS( -DASSIMP_IMPORTER_GLTF_USE_OPEN3DGC=1 )
@@ -1274,10 +1276,17 @@ SET_TARGET_PROPERTIES( assimp PROPERTIES
12741276
OUTPUT_NAME assimp${LIBRARY_SUFFIX}
12751277
)
12761278

1277-
if (WIN32 AND CMAKE_COMPILER_IS_GNUCXX AND BUILD_SHARED_LIBS)
1278-
set_target_properties(assimp PROPERTIES
1279-
SUFFIX "-${ASSIMP_SOVERSION}${CMAKE_SHARED_LIBRARY_SUFFIX}"
1280-
)
1279+
if (MINGW)
1280+
if (BUILD_SHARED_LIBS)
1281+
set_target_properties(assimp PROPERTIES
1282+
SUFFIX "-${ASSIMP_SOVERSION}${CMAKE_SHARED_LIBRARY_SUFFIX}"
1283+
)
1284+
if (NOT DEFINED ${LIBRARY_SUFFIX}) #Added as a guard for subsequent runs, but seems to not work when cache is outdated
1285+
set(LIBRARY_SUFFIX "-${ASSIMP_SOVERSION}" CACHE STRING "the suffix for the assimp MinGW shared library")
1286+
endif()
1287+
else ()
1288+
TARGET_LINK_LIBRARIES ( assimp -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lwinpthread ) # winpthread is for libminizip.
1289+
endif ()
12811290
endif()
12821291

12831292
if (APPLE)

code/Common/DefaultIOStream.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ inline int select_fseek(FILE *file, int64_t offset, int origin) {
6363

6464

6565

66-
#if defined _WIN32 && (!defined __GNUC__ || __MSVCRT_VERSION__ >= 0x0601)
66+
#if defined _WIN64 && (!defined __GNUC__ || __MSVCRT_VERSION__ >= 0x0601)
6767
template <>
6868
inline size_t select_ftell<8>(FILE *file) {
6969
return (size_t)::_ftelli64(file);
@@ -149,7 +149,7 @@ size_t DefaultIOStream::FileSize() const {
149149
//
150150
// See here for details:
151151
// https://www.securecoding.cert.org/confluence/display/seccode/FIO19-C.+Do+not+use+fseek()+and+ftell()+to+compute+the+size+of+a+regular+file
152-
#if defined _WIN32 && (!defined __GNUC__ || __MSVCRT_VERSION__ >= 0x0601)
152+
#if defined _WIN64 && (!defined __GNUC__ || __MSVCRT_VERSION__ >= 0x0601)
153153
struct __stat64 fileStat;
154154
//using fileno + fstat avoids having to handle the filename
155155
int err = _fstat64(_fileno(mFile), &fileStat);

revision.h.in

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@
1818
#else
1919
#define VER_FILEVERSION_STR STR(VER_MAJOR) "." STR(VER_MINOR) "." STR(VER_PATCH) "." STR(VER_BUILD) " (Commit @GIT_COMMIT_HASH@)"
2020
#endif
21+
#define VER_COPYRIGHT_STR "\xA9 2006-2022"
2122

2223
#ifdef NDEBUG
23-
#define VER_ORIGINAL_FILENAME_STR "assimp@[email protected]"
24+
#define VER_ORIGINAL_FILENAME_STR "@CMAKE_SHARED_LIBRARY_PREFIX@assimp@[email protected]"
2425
#else
25-
#define VER_ORIGINAL_FILENAME_STR "assimp@LIBRARY_SUFFIX@@[email protected]"
26+
#define VER_ORIGINAL_FILENAME_STR "@CMAKE_SHARED_LIBRARY_PREFIX@assimp@LIBRARY_SUFFIX@@[email protected]"
2627
#endif // NDEBUG
2728

2829
#endif // ASSIMP_REVISION_H_INC

tools/assimp_view/CMakeLists.txt

-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@
3939
#----------------------------------------------------------------------
4040
cmake_minimum_required( VERSION 3.10 )
4141

42-
FIND_PACKAGE(DirectX REQUIRED)
43-
4442
INCLUDE_DIRECTORIES (
4543
${Assimp_SOURCE_DIR}/include
4644
${Assimp_SOURCE_DIR}/code

0 commit comments

Comments
 (0)