On 12/21/2010 2:17 PM, Michael Hertling wrote:

AFAIK, this is because CMake does not know how to handle a .def file
for incorporation in the target, i.e. ${library}.def has no LANGUAGE

Actually, it should...


Something like this should work:
(assumes you have a perl script to create a .def file)

cmake_minimum_required (VERSION 2.6)
project (myexe)

set (SOURCES mylib.cxx mylib2.cxx)

# create a list of all the object files
string (REGEX REPLACE "\\.cxx" ".obj" OBJECTS "${SOURCES}")

# create a shared library with the .def file
add_library (mylib SHARED ${SOURCES}
  ${CMAKE_CURRENT_BINARY_DIR}/mylib.def
  )
# set the .def file as generated
set_source_files_properties (
  ${CMAKE_CURRENT_BINARY_DIR}/mylib.def
  PROPERTIES GENERATED 1
  )

# create an executable
add_executable (myexe myexe.cxx)

# link the executable to the dll
target_link_libraries(myexe mylib)

#convert to windows slashes
set (OUTDIR
  ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}
  )

string (REGEX REPLACE "/" "\\\\" OUTDIR ${OUTDIR})

# create a custom pre link command that runs
# a perl script to create a .def file using dumpbin
add_custom_command (
  TARGET mylib PRE_LINK
  COMMAND perl
  ARGS ${CMAKE_CURRENT_SOURCE_DIR}/makedef.pl
  ${CMAKE_CURRENT_BINARY_DIR}\\mylib.def mylib
  ${OUTDIR} ${OBJECTS} )
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to