1if (NOT CMAKE_HOST_UNIX OR NOT WIN32) 2 return() 3endif() 4 5find_program(WINTOOLS_WINE_EXEC wine) 6if (NOT WINTOOLS_WINE_EXEC) 7 message("Wine executable not found! Failed to initiate wintools staff.") 8 return() 9endif() 10 11find_program(WINTOOLS_WGET_EXEC wget) 12if (NOT WINTOOLS_WGET_EXEC) 13 message("Wget executable not found! Failed to initiate wintools staff.") 14 return() 15endif() 16 17set(WINTOOLS_DIR ${CMAKE_BINARY_DIR}/WINTOOLS) 18set(WINTOOLS_DL_ROOT "http://softmotions.com/windev") 19 20if (NOT EXISTS ${WINTOOLS_DIR}) 21 file(MAKE_DIRECTORY ${WINTOOLS_DIR}) 22endif() 23 24set(WINTOOLS_EXECS) 25foreach (WINTOOLS_EXEC link.exe lib.exe mspdb100.dll) 26 if (NOT EXISTS ${WINTOOLS_DIR}/${WINTOOLS_EXEC}) 27 add_custom_command(OUTPUT ${WINTOOLS_DIR}/${WINTOOLS_EXEC} 28 COMMAND ${WINTOOLS_WGET_EXEC} ${WINTOOLS_DL_ROOT}/${WINTOOLS_EXEC} -nv -O${WINTOOLS_DIR}/${WINTOOLS_EXEC} 29 WORKING_DIRECTORY ${WINTOOLS_DIR}) 30 list(APPEND WINTOOLS_EXECS ${WINTOOLS_DIR}/${WINTOOLS_EXEC}) 31 endif() 32endforeach(WINTOOLS_EXEC) 33 34add_custom_target(wintools_init 35 DEPENDS ${WINTOOLS_EXECS}) 36 37if (CMAKE_SIZEOF_VOID_P MATCHES 8) 38 set(WINTOOLS_LIB_MACHINE "X64") 39else() 40 set(WINTOOLS_LIB_MACHINE "X86") 41endif() 42message("${PROJECT_NAME} WINTOOLS_LIB_MACHINE: ${WINTOOLS_LIB_MACHINE}") 43 44macro(add_w32_importlib tgt libname wdir) 45 add_custom_command( 46 TARGET ${tgt} 47 POST_BUILD 48 COMMAND ${WINTOOLS_WINE_EXEC} ${WINTOOLS_DIR}/lib.exe /def:${libname}.def /machine:${WINTOOLS_LIB_MACHINE} 49 WORKING_DIRECTORY ${wdir} 50 ) 51endmacro(add_w32_importlib) 52 53 54