[CMake] Plugins (Modules) on Windows

bpwlist at cox.net bpwlist at cox.net
Mon Mar 5 19:09:40 EST 2007


Hi All,

I have a project in which I build a main application and several plugins (modules).  My main cmake file look something like this:

ADD_SUBDIRECTORY(MainApp)
ADD_SUBDIRECTORY(plugins/Plugin1)
ADD_SUBDIRECTORY(plugins/Plugin2)
...

Plugin1 cmakes file looks like this:
PROJECT(Plugin1)
INCLUDE_DIRECTORIES(
    .
    ${CMAKE_SOURCE_DIR}/MyApp
)

SET (SRCS foo.cpp)

ADD_LIBRARY(Plugin1 MODULE ${SRCS})

MyApp's Cmake file looks like this:

PROJECT(MyApp)
SET (SRCS bar.cpp)
ADD_EXECUTABLE(MyApp ${SRCS}

This works great on linux.  But under windows I get several unresolved symbols.  Under linux the symbols are resolved when the module is loaded by MyApp, under windows the symbols are trying to be resolved by the linker.  I can fix this in Visual Studio by adding MyApp.lib to the list of dependencies.  MyApp.lib is generated as a side effect of VS building the executable.   When I try add MyApp.lib under cmake it appears to get confused.  (since MyApp is a executable not a library)  What is the right way of doing this?

Thanks,

Bryan Walsh




More information about the CMake mailing list