As you can see form here (How to Specify the Compiler and To Compile Different Main Functions) I am new to CMake and I still have problem. The previous question helped me to understand CMake, but I still have problems. First of all, even if I wrote the following lines in my CMakeLists.txt
set(CMAKE_CXX_COMPILER /opt/local/bin/g++)
set(CMAKE_CXX_FLAGS "-Wall -std=c++11")
the compiler used seems to be Clang and not g++. In addition when compiling (I get rid of all code errors) I obtain this message:
[ 33%] Built target Output
[ 66%] Built target Vector
Scanning dependencies of target Output_test
[100%] Building CXX object tests/CMakeFiles/Output_test.dir/output_test.cpp.o
Linking CXX executable Output_test
ld: library not found for -lIO
collect2: error: ld returned 1 exit status
make[2]: *** [tests/Output_test] Error 1
make[1]: *** [tests/CMakeFiles/Output_test.dir/all] Error 2
make: *** [all] Error 2
Do you know what I am doing wrong?
Edit: In the root folder
cmake_minimum_required (VERSION 2.8.11)
project (MC)
set(CMAKE_CXX_COMPILER /opt/local/bin/g++)
set(CMAKE_CXX_FLAGS "-Wall -std=c++11")
# Class definitions
add_subdirectory(IO)
add_subdirectory(math)
# Tests
add_subdirectory(tests)
In the IO folder:
add_library(Output Output.cpp)