Once again I am getting a "undefined symbols for architecture x86_64" error when I try to compile. I've tried more than I can actually document in this post (because I've forgotten all that I have tried). It is a really simple set-up and should compile very easily with CMake...
When I run a make on this it works just fine. But I want to convert it to CMake for interoperability. As you can see I have thrown my "${HEADERS}" variable in a few places, I've tried quite a few placements of it but I keep getting my error. Depending on where I put that ${HEADER} it can also technically generate an error of "error: cannot specify -o when generating multiple output files" (That applies if it only sits in the target_link_library declaration).
I have 2 folders:
Root
Headers (contains all .h files)
Source (contains all .cc/.cpp/.c files) (and also a CMakeLists.txt)
CMakeLists.txt
My root CMakeLists.txt contains the following:
cmake_minimum_required(VERSION 2.8.4)
project(Framework)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
add_compile_options("-v")
add_subdirectory(Source)
#Variables for making my life easier and adding the headers
set(H Headers)
include_directories(${H})
set(S Source)
file(GLOB HEADERS
#Add any file in the headers dir
"${H}/*"
)
# Create a variable to use for main.cc
set(MAIN ${S}/main.cc ${HEADERS})
# Add the main.cc file and headers
add_executable(Framework ${MAIN} ${HEADERS})
# Add the .cc/.cpp files
target_link_libraries(Framework ${SOURCE_FILES})
My CMakeLists.txt in my source directory contains the following:
file(GLOB SOURCES
"*.cc"
"*.cpp"
)
add_library(SOURCE_FILES ${SOURCES})
I do not have one in the headers as per, what I believe, the documentation states we don't need.
Thanks for the help. I've looked at:
- cmake including h files from other directories
- http://www.cmake.org/cmake/help/v2.8.0/cmake.html (both for version 2.x and 3.x)
- CMake Adding Headers to Projectfile -- had a potential for a solution but ended up saying "I don't know" :(
- and many other various mail lists and other sites