Hello, First off, you cannot call both add_executable and add_library in the same CMakeLists file. Here is what I can say about your other questions:
1. All commands that require a target have to come after you have created the target via add_executable or add_library. This is simply because you need to have a target before you can adds things to it. 2. I am not real sure why this would work. But, for common practices, you should always call target_link_libraries after your call to add_library or add_executable for the reason stated above. 3. Again, this is the same answer. It will work as long as you make the call to the command after add_library or add_executable. Hope this helps. Eric From: cmake-boun...@cmake.org [mailto:cmake-boun...@cmake.org] On Behalf Of ?? Sent: Monday, October 22, 2012 10:25 AM To: cmake@cmake.org Subject: [CMake] cmake trouble Hello: I am using cmake for three months now. but was trouble in a situation 。for details bellow: (in Windows) ADD_LIBRARY(test SHARED ${LIBTEST_SRC} ${LIBHELLO_SRC}) #ADD_LIBRARY(test STATIC ${LIBTEST_SRC} ${LIBHELLO_SRC}) #add executable AUX_SOURCE_DIRECTORY(. FAN_SRC) TARGET_LINK_LIBRARIES(fan test) ADD_EXECUTABLE(fan ${FAN_SRC}) 1.if i put "TARGET_LINK_LIBRARIES(fan test)" before ADD_EXECUTABLE command,this does not work ,why?? 2. but if i ADD_LIBRARY(test STATIC ${LIBTEST_SRC} ${LIBHELLO_SRC}) ,it is ok,why ?? 3.if i put "TARGET_LINK_LIBRARIES(fan test)" after ADD_EXECUTABLE command,it works ,why ?? I am waiting for your help !! With best wishes.<app:lj:%E6%AD%A4%E8%87%B4%E6%95%AC%E7%A4%BC?ljtype=blng&ljblngcont=0&ljtran=With%20best%20%20wishes.>
-- 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