-1

im getting this linker warning. how do i fix it using cmake? here's my root CMakeLists.txt:

# 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)
Musaffa
  • 702
  • 8
  • 14
  • Do your subdirectories have their own `CMakeLists.txt`? AFAIK that's expected with `add_subdirectory`. – Cheezmeister Feb 23 '11 at 00:43
  • What linker warning are you getting? What version of CMake are you using? What compiler? – DLRdave Feb 23 '11 at 03:00
  • @Cheezmeister subdirectories have their own CMakeLists.txt. im running the program perfectly. just want to remove the warning. @DLRdave Compiler GCC. cmake version 2.8. ld.exe: warning: auto-importing has been activated without --enable-auto-import specified on the command line – Musaffa Feb 23 '11 at 09:41

2 Answers2

1

finally found the answer after a lot of searching:

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

learning cmake isn't easy bcoz of its bad documentation. "mastering cmake" book should be made free. excerpt of a chapter wont do.

Musaffa
  • 702
  • 8
  • 14
0

For shared libraries, I also had to set this:

set(
CMAKE_SHARED_LIBRARY_CXX_FLAGS 
"${CMAKE_SHARED_LIBRARY_CXX_FLAGS} -Wl,--enable-auto-import "
)
hecvd
  • 659
  • 1
  • 8
  • 24