So I tuned up verbosity on the make files produced by cmake and shut of cmake rule messages (by adding -DCMAKERULEMESSAGES:BOOL=OFF -DCMAKEVERBOSEMAKEFILE:BOOL=ON to the cmake call). In this chapter we start by installing CMake. Like most open source software the best way to do this depends on your platform and how you usually do things. Once we have CMake installed we create a simple project. Perhaps it's a little fancier than 'hello world' but not much. We finish up with the Continue reading 'CMake Tutorial – Chapter 1: Getting Started'. Ld: building for iOS simulator, but linking against dylib built for OSX, file '/usr/lib/libSystem.dylib' for architecture x8664. When trying to learn CMake I could not find any good introduction. The CMake documentation is quite comprehensive but not suitable for a beginner. There are some useful tutorials linked on the CMake.
The plugin libraries are loaded by the application at run time. 'xcb' is a platform plugin for GNU/Linux. You may need others depending on your application.
project(foo) |
SET(CMAKE_EXE_LINKER_FLAGS -static) |
# add ZeroMQ library |
add_library(imp_zeromq STATICIMPORTED) |
set_property(TARGET imp_zeromq PROPERTY |
IMPORTED_LOCATION$ENV{ZEROMQ_HOME}/libzmq.a) |
# add C bindings for ZeroMQ library |
add_library(imp_zeromq STATICIMPORTED) |
set_property(TARGET imp_czmq PROPERTY |
IMPORTED_LOCATION$ENV{CZMQ_HOME}/libczmq.a) |
add_library(Config ./Config/Config.c ./Config.minIni.c) |
add_library(Comm ./Comm/Comm.c) |
add_executable(Runtime Runtime.cpp) |
target_link_libraries(Runtime imp_zeromq imp_czmq ${CMAKE_THREAD_LIBS_INIT} rt Comm Config) |
------------- Failure on Ubuntu 12.04 ---------------- |
make -f src/CMakeFiles/Runtime.dir/build.make src/CMakeFiles/Runtime.dir/depend |
make[2]: Entering directory `/home/davis/git/firmware/build' |
cd /home/davis/git/firmware/build && /usr/bin/cmake -E cmake_depends 'Unix Makefiles' |
/home/davis/git/firmware /home/davis/git/firmware/src /home/davis/git/firmware/build |
/home/davis/git/firmware/build/src /home/davis/git/firmware/build/src/CMakeFiles/Runtime.dir/DependInfo.cmake --color= |
make[2]: Leaving directory `/home/davis/git/firmware/build' |
make -f src/CMakeFiles/Runtime.dir/build.make src/CMakeFiles/Runtime.dir/build |
make[2]: Entering directory `/home/davis/git/firmware/build' |
Linking CXX executable ../bin/Runtime |
cd /home/davis/git/firmware/build/src && /usr/bin/cmake -E cmake_link_script CMakeFiles/Runtime.dir/link.txt --verbose=1 |
/usr/bin/c++ -static CMakeFiles/Runtime.dir/Runtime.cpp.o -o ../bin/Runtime |
-rdynamic /usr/local/lib/libzmq.a /usr/local/lib/libczmq.a -lpthread -lrt ../lib/libComm.a ../lib/libConfig.a |
../lib/libComm.a(Comm.c.o): In function `Comm_Create': |
Comm.c:(.text+0x42): undefined reference to `zctx_new' |
Comm.c:(.text+0x5c): undefined reference to `zsocket_new' |
collect2: ld returned 1 exit status |
make[2]: *** [bin/Runtime] Error 1 |
make[2]: Leaving directory `/home/davis/git/firmware/build' |
make[1]: *** [src/CMakeFiles/Runtime.dir/all] Error 2 |
make[1]: Leaving directory `/home/davis/git/firmware/build' |
make: *** [all] Error 2 |
------------ Success on Mac OS X ------------------ |
make -f src/CMakeFiles/Runtime.dir/build.make src/CMakeFiles/Runtime.dir/depend |
cd /Users/davis/git/firmware/build && /usr/local/Cellar/cmake/2.8.9/bin/cmake -E cmake_depends 'Unix Makefiles' |
/Users/davis/git/firmware /Users/davis/git/firmware/src /Users/davis/git/firmware/build /Users/davis/git/firmware/build/src |
/Users/davis/git/firmware/build/src/CMakeFiles/Runtime.dir/DependInfo.cmake --color= |
make -f src/CMakeFiles/Runtime.dir/build.make src/CMakeFiles/Runtime.dir/build |
/usr/local/Cellar/cmake/2.8.9/bin/cmake -E cmake_progress_report /Users/davis/git/firmware/build/CMakeFiles 7 |
[ 50%] Building CXX object src/CMakeFiles/Runtime.dir/Runtime.cpp.o |
cd /Users/davis/git/firmware/build/src && /usr/bin/c++ -I/Users/davis/git/firmware/src/../include |
-I/Users/davis/git/firmware/src/../include/LedDriver -I/usr/local/Cellar/msgpack/0.5.7/include |
-o CMakeFiles/Runtime.dir/Runtime.cpp.o -c /Users/davis/git/firmware/src/Runtime.cpp |
Linking CXX executable ../bin/Runtime |
cd /Users/davis/git/firmware/build/src && /usr/local/Cellar/cmake/2.8.9/bin/cmake -E cmake_link_script CMakeFiles/Runtime.dir/link.txt --verbose=1 |
/usr/bin/c++ -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/Runtime.dir/Runtime.cpp.o -o ../bin/Runtime |
-L/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1/x86_64 |
-L/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1/x86_64 |
-L/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1 |
-L/usr/llvm-gcc-4.2/lib/gcc |
-L/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1 |
-L/usr/llvm-gcc-4.2/lib -L/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/lib |
../lib/libComm.a ../lib/libConfig.a /usr/local/lib/libzmq.a /usr/local/lib/libczmq.a |
/usr/local/Cellar/cmake/2.8.9/bin/cmake -E cmake_progress_report /Users/davis/git/firmware/build/CMakeFiles 7 |
[ 50%] Built target Runtime |
------------- Failure on Ubuntu 12.04 ---------------- |
make -f src/CMakeFiles/Runtime.dir/build.make src/CMakeFiles/Runtime.dir/depend |
make[2]: Entering directory `/home/davis/git/firmware/build' |
cd /home/davis/git/firmware/build && /usr/bin/cmake -E cmake_depends 'Unix Makefiles' |
/home/davis/git/firmware /home/davis/git/firmware/src /home/davis/git/firmware/build |
/home/davis/git/firmware/build/src /home/davis/git/firmware/build/src/CMakeFiles/Runtime.dir/DependInfo.cmake --color= |
make[2]: Leaving directory `/home/davis/git/firmware/build' |
make -f src/CMakeFiles/Runtime.dir/build.make src/CMakeFiles/Runtime.dir/build |
make[2]: Entering directory `/home/davis/git/firmware/build' |
Linking CXX executable ../bin/Runtime |
cd /home/davis/git/firmware/build/src && /usr/bin/cmake -E cmake_link_script CMakeFiles/Runtime.dir/link.txt --verbose=1 |
/usr/bin/c++ -static CMakeFiles/Runtime.dir/Runtime.cpp.o -o ../bin/Runtime |
-rdynamic /usr/local/lib/libzmq.a /usr/local/lib/libczmq.a -lpthread -lrt ../lib/libComm.a ../lib/libConfig.a |
../lib/libComm.a(Comm.c.o): In function `Comm_Create': |
Comm.c:(.text+0x42): undefined reference to `zctx_new' |
Comm.c:(.text+0x5c): undefined reference to `zsocket_new' |
collect2: ld returned 1 exit status |
make[2]: *** [bin/Runtime] Error 1 |
make[2]: Leaving directory `/home/davis/git/firmware/build' |
make[1]: *** [src/CMakeFiles/Runtime.dir/all] Error 2 |
make[1]: Leaving directory `/home/davis/git/firmware/build' |
make: *** [all] Error 2 |
------------ Success on Mac OS X ------------------ |
make -f src/CMakeFiles/Runtime.dir/build.make src/CMakeFiles/Runtime.dir/depend |
cd /Users/davis/git/firmware/build && /usr/local/Cellar/cmake/2.8.9/bin/cmake -E cmake_depends 'Unix Makefiles' |
/Users/davis/git/firmware /Users/davis/git/firmware/src /Users/davis/git/firmware/build /Users/davis/git/firmware/build/src |
/Users/davis/git/firmware/build/src/CMakeFiles/Runtime.dir/DependInfo.cmake --color= |
make -f src/CMakeFiles/Runtime.dir/build.make src/CMakeFiles/Runtime.dir/build |
/usr/local/Cellar/cmake/2.8.9/bin/cmake -E cmake_progress_report /Users/davis/git/firmware/build/CMakeFiles 7 |
[ 50%] Building CXX object src/CMakeFiles/Runtime.dir/Runtime.cpp.o |
cd /Users/davis/git/firmware/build/src && /usr/bin/c++ -I/Users/davis/git/firmware/src/../include |
-I/Users/davis/git/firmware/src/../include/LedDriver -I/usr/local/Cellar/msgpack/0.5.7/include |
-o CMakeFiles/Runtime.dir/Runtime.cpp.o -c /Users/davis/git/firmware/src/Runtime.cpp |
Linking CXX executable ../bin/Runtime |
cd /Users/davis/git/firmware/build/src && /usr/local/Cellar/cmake/2.8.9/bin/cmake -E cmake_link_script CMakeFiles/Runtime.dir/link.txt --verbose=1 |
/usr/bin/c++ -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/Runtime.dir/Runtime.cpp.o -o ../bin/Runtime |
-L/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1/x86_64 |
-L/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1/x86_64 |
-L/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1 |
-L/usr/llvm-gcc-4.2/lib/gcc |
-L/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1 |
-L/usr/llvm-gcc-4.2/lib -L/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/lib |
../lib/libComm.a ../lib/libConfig.a /usr/local/lib/libzmq.a /usr/local/lib/libczmq.a |
/usr/local/Cellar/cmake/2.8.9/bin/cmake -E cmake_progress_report /Users/davis/git/firmware/build/CMakeFiles 7 |
[ 50%] Built target Runtime |
- CMake Error at /usr/share/cmake-3.5/Modules/CMakeTestCCompiler.cmake:61 (message):
- The C compiler '/usr/bin/i686-w64-mingw32-gcc' is not able to compile a
- Change Dir: /home/chemicalchems/SFML-2.3.2/build/CMakeFiles/CMakeTmp
- Run Build Command:'/usr/bin/make' 'cmTC_9b6e7/fast'
- /usr/bin/make -f CMakeFiles/cmTC_9b6e7.dir/build.make
- '/home/chemicalchems/SFML-2.3.2/build/CMakeFiles/CMakeTmp'
- Building C object CMakeFiles/cmTC_9b6e7.dir/testCCompiler.c.o
- /usr/bin/i686-w64-mingw32-gcc -o
- /home/chemicalchems/SFML-2.3.2/build/CMakeFiles/CMakeTmp/testCCompiler.c
- Linking C executable cmTC_9b6e7
- /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_9b6e7.dir/link.txt
- /usr/bin/i686-w64-mingw32-gcc CMakeFiles/cmTC_9b6e7.dir/testCCompiler.c.o
- i686-w64-mingw32-gcc: error: unrecognized command line option
- CMakeFiles/cmTC_9b6e7.dir/build.make:97: recipe for target 'cmTC_9b6e7'
- '/home/chemicalchems/SFML-2.3.2/build/CMakeFiles/CMakeTmp'
- Makefile:126: recipe for target 'cmTC_9b6e7/fast' failed
- make: *** [cmTC_9b6e7/fast] Error 2
- set(CMAKE_SYSTEM_NAME Generic)
- set(CMAKE_CROSSCOMPILING 1)
- set(CMAKE_C_COMPILER_WORKS 1)
- set(TOOLCHAIN_PREFIX i686-w64-mingw32)
- # cross compilers to use for C and C++
- set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
- set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)
- # target environment on the build host system
- # set 1st to dir with the cross compiler's C/C++ headers/libs
- set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
- # modify default behavior of FIND_XXX() commands to
- # search for headers/libs in the target environment and
- # search for programs in the build host environment
- set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)