Here is my compiler part of my config:
IF(UNIX)
## Compiler flags
# specify the cross compiler
SET(CMAKE_C_COMPILER /home/username/projects/buildroot/output/host/usr/bin/arm-linux-gcc)
SET(CMAKE_CXX_COMPILER /home/username/projects/buildroot/output/host/usr/bin/arm-linux-g++)
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "-O3")
set(CMAKE_EXE_LINKER_FLAGS "-lsqlite3 -lrt -lpthread")
endif()
target_link_libraries(complex
${Boost_FILESYSTEM_LIBRARY}
${Boost_SYSTEM_LIBRARY})
ENDIF(UNIX)
There are 3 problems : -lsqlite3 -lrt -lpthread
How must I to make them for my architecture and specify here? How to set (using set?) the path of compiled libraries after I will get them recompiled for my architecture somehow?
If you want to do cross-compilation with CMake you really should use a toolchain file for that. See the CMake Wiki for an introduction. In order to use third-party libraries (i.e. not included by the cross-compilation toolchain) you need to cross-compile them too.
Edit: Since you are using the buildroot toolchain, you can use the already included CMake toolchain file. Just pass
-DCMAKE_TOOLCHAIN_FILE=/home/username/projects/buildroot/output/toolchainfile.cmake
when invoking CMake. No need to setCMAKE_C_COMPILER
andCMAKE_CXX_COMPILER
in yourCMakeLists.txt
file. Also, settingCMAKE_CXX_FLAGS
andCMAKE_EXE_LINKER_FLAGS
is considered to be very bad practice.Presumably you have built sqlite3 while building the buildroot toolchain, so you can use it just like any other library. I.e:
Lastly, do not set
CMAKE_CXX_FLAGS
to-O3
. The user should pass-DCMAKE_BUILD_TYPE=Release
when configuring the project instead.You'll have to cross-compile the dependencies as well. The path depends on where you install them.
Btw., using
-lpthread
is not the safe way of getting POSIX threads. You should give the option-pthread
to both the compiler and the linker.