On 09/16/2010 05:33 PM, Michael Wild wrote: > > On 16. Sep, 2010, at 17:13 , David Aldrich wrote: > >> Hi David >> >>> Something like this should work: >> >>> cmake_minimum_required(VERSION 2.8) >>> project(MyExe) >> >>> add_subdirectory(../Kernel Kernel) >>> add_subdirectory(../DynLibs DynLibs) >> >>> add_executable(MyExe exe.cxx) >>> target_link_libraries(MyExe Kernel) >> >> I have a problem with add_executable(). Our Kernel library includes >> main.cpp, so all our existing linker command does is to take libKernel.a and >> make it an executable: >> >> g++ -o _gnuRelease/MyExe -ldl -Wl,-whole-archive,-export-dynamic >> ../Kernel/_gnuRelease/libKernel.a >> >> So I have no source files to specify. Does 'exe.cxx' (above) have special >> properties or is it just a placeholder? If the latter, how can I build an >> executable with no source files specified? >> >> BR >> >> David > > There is none. The only way to do that is create an empty dummy file (using > e.g. a combination of file(WRITE) and configure_file() to prevent recompiling > after every CMake run).
Just for my curiosity: On *nix, I can see the following CMakeLists.txt work: CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR) PROJECT(EXELIB C) FILE(WRITE ${CMAKE_BINARY_DIR}/main.c "int main(void){return 0;}\n") ADD_LIBRARY(main STATIC main.c) ADD_EXECUTABLE(exe "") SET_TARGET_PROPERTIES(exe PROPERTIES LINKER_LANGUAGE C) TARGET_LINK_LIBRARIES(exe main) Note the double quotes within ADD_EXECUTABLE(). The link line for exe is: gcc -o exe -rdynamic libmain.a I.e., rather the one David desires. So, does this work by accident and possibly on *nix only? Regards, Michael _______________________________________________ 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