Skip to content

Commit

Permalink
Do not print warning for missing def file when building static libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
Lectem committed Jan 2, 2024
1 parent 77d3fd4 commit 5ddb15b
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions cmake/D2MOO.TargetsHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,26 @@ function(D2MOO_configure_exports DLLTargetName)
set(options FORCE_EXPORT IGNORE_MISSING_DEF)
cmake_parse_arguments(PARSE_ARGV 1 this "${options}" "" "")

get_target_property(Library_TYPE ${DLLTargetName} TYPE)
string(TOUPPER "${DLLTargetName}" DLLTargetNameUpperCase)
set(EXPORT_IF_SHARED_LIB "$<$<STREQUAL:$<TARGET_PROPERTY:${DLLTargetName},TYPE>,SHARED_LIBRARY>:__declspec( dllexport )>")
set(IMPORT_IF_SHARED_LIB "$<$<STREQUAL:$<TARGET_PROPERTY:${DLLTargetName},TYPE>,SHARED_LIBRARY>:__declspec( dllimport )>")

D2MOO_get_def_file(${DLLTargetName} DEF_FILE_NAME)

if(EXISTS "${DEF_FILE_NAME}")
set(ShouldExportIfSharedLib ${this_FORCE_EXPORT})
target_sources(${DLLTargetName} PRIVATE "${DEF_FILE_NAME}")
else()
set(ShouldExportIfSharedLib TRUE)
if(NOT this_IGNORE_MISSING_DEF)
message(WARNING "Def file '${DEF_FILE_NAME}' not found.")
endif()

set(ShouldExport ${this_FORCE_EXPORT})
if(Library_TYPE STREQUAL SHARED_LIBRARY)
set(EXPORT_IF_SHARED_LIB "__declspec( dllexport )")
set(IMPORT_IF_SHARED_LIB "__declspec( dllimport )")
D2MOO_get_def_file(${DLLTargetName} DEF_FILE_NAME)
if(EXISTS "${DEF_FILE_NAME}")
target_sources(${DLLTargetName} PRIVATE "${DEF_FILE_NAME}")
else()
set(ShouldExport TRUE)
if(BUILD_SHARED_LIBS AND NOT this_IGNORE_MISSING_DEF)
message(WARNING "Def file '${DEF_FILE_NAME}' not found.")
endif()
endif()
else()
endif()

if(ShouldExportIfSharedLib)
if(ShouldExport)
D2MOO_set_dll_decl(${DLLTargetName} "${EXPORT_IF_SHARED_LIB}" "${IMPORT_IF_SHARED_LIB}")
else()
D2MOO_set_dll_decl(${DLLTargetName} "" "${IMPORT_IF_SHARED_LIB}")
Expand Down

0 comments on commit 5ddb15b

Please sign in to comment.