2011-02-23 44 views
0

即時獲取此鏈接警告。我如何使用cmake修復它?這裏是我的根的CMakeLists.txt:如何刪除 - 使用cmake啓用 - 自動導入警告

# CMakeLists.txt/

cmake_minimum_required(VERSION 2.8) 

project(FactoryPattern) 

include_directories(stores/include) 

add_subdirectory(factories) 
add_subdirectory(ingredients) 
add_subdirectory(stores) 

add_executable(factory MyPizzaStore.cpp) 

target_link_libraries(factory pizzaStore) 
+0

做你的子目錄中有自己的'CMakeLists.txt'? AFAIK與'add_subdirectory'預期相同。 – Cheezmeister 2011-02-23 00:43:24

+0

你會得到什麼鏈接警告?你使用的是哪個版本的CMake?什麼編譯器? – DLRdave 2011-02-23 03:00:12

+0

@Cheezmeister子目錄擁有自己的CMakeLists.txt。即時運行程序完美。只是想刪除警告。 @DLRdave編譯器GCC。 cmake 2.8版。 ld.exe:警告:未在命令行中指定--enable-auto-import而未激活自動導入 – Musaffa 2011-02-23 09:41:02

回答

1

終於找到了答案很多搜索後:

set(CMAKE_EXE_LINKER_FLAGS 
"${CMAKE_EXE_LINKER_FLAGS} -Wl,-enable-auto-import" 
) 

學習CMake的不容易bcoz其糟糕的文檔。 「掌握cmake」的書應該免費。一章的摘錄不會做。

0

共享庫,我也不得不設置此:

set(
CMAKE_SHARED_LIBRARY_CXX_FLAGS 
"${CMAKE_SHARED_LIBRARY_CXX_FLAGS} -Wl,--enable-auto-import " 
)