Reputation:
This is the way how I compile my cpp code:
g++ -I/usr/local/include/modbus `pkg-config glib-2.0 --cflags --libs` -L/usr/local/lib -lmodbus test-modbus.c -o test-modbus
with gcc it is working pretty fine. But I need to place it into CmakeList.txt and I tried this:
SET(GCC_COVERAGE_COMPILE_FLAGS "-I/usr/local/include/modbus -L/usr/local/lib")
SET(GCC_COVERAGE_LINK_FLAGS "-lmodbus")
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}" )
SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_COVERAGE_LINK_FLAGS}" )
But with no success. Any ideas?
Upvotes: 0
Views: 1331
Reputation: 5308
CMake aims to be platform- and compiler-independent, so you don't set specific compiler flags, but you tell CMake what you want to do. For example, the include_directories
command adds directories to the include path (similar to gcc's -I
option), target_link_libraries
links a library (similar to gcc's -l
) option, pkg_config
can be called through the PkgConfig
module, and so on.
Upvotes: 1