simplify CMakeList with cmake scripts

This commit is contained in:
qPCR4vir
2018-09-10 14:27:56 +02:00
parent 8057bf95e1
commit 8c6b0d4653
7 changed files with 149 additions and 147 deletions

View File

@@ -0,0 +1,30 @@
if(WIN32)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
if(MSVC)
set(DLLTOOL OFF)
else()
# mingw: If dlltool is found the def and lib file will be created
find_program (DLLTOOL dlltool)
if(NOT DLLTOOL)
message(WARNING "dlltool not found. Skipping import library generation.")
endif()
endif()
if(DLLTOOL)
#generate the lib and def files needed by msvc
set_target_properties (nana PROPERTIES
OUTPUT_NAME nana
ARCHIVE_OUTPUT_NAME nana
LINK_FLAGS "${CMAKE_SHARED_LINKER_FLAGS_INIT} -Wl,--output-def=${CMAKE_CURRENT_BINARY_DIR}/libnana.def"
)
add_custom_command(TARGET nana POST_BUILD
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
COMMAND echo " Generating import library"
COMMAND "${DLLTOOL}" --dllname "libnana.dll"
--input-def "libnana.def"
--output-lib "libnana.lib")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libnana.def"
"${CMAKE_CURRENT_BINARY_DIR}/libnana.lib" DESTINATION lib)
endif()
endif()