Tag Archives: cmake

Configure CMake to use GLIB

cmake_minimum_required(VERSION 3.8)
project(msync_server)

FIND_PACKAGE(PkgConfig)
PKG_CHECK_MODULES(GLIB glib-2.0)

include_directories(${GLIB_INCLUDE_DIRS})
link_directories(${GLIB_LIBRARY_DIRS})
add_definitions(${GLIB_CFLAGS_OTHER})

set(CMAKE_C_STANDARD 99)

set(SOURCE_FILES main.c)
add_executable(msync_server ${SOURCE_FILES} ${Glib_LIBRARY})

References
https://github.com/gammu/gammu/blob/master/cmake/FindGlib.cmake

Configure CMake to use GTK

First install libgtk-3-dev and libgtkmm-3.0-dev then :

cmake_minimum_required(VERSION 3.7)
project(project1)

include(FindPkgConfig)
pkg_check_modules(GTK REQUIRED "gtk+-3.0")

include_directories(${GTK_INCLUDE_DIRS})
link_directories(${GTK3_LIBRARY_DIRS})
add_definitions(${GTK3_CFLAGS_OTHER})

set(CMAKE_CXX_STANDARD 11)
set(SOURCE_FILES main.cpp)
add_executable(untitled ${SOURCE_FILES})
target_link_libraries(${CMAKE_PROJECT_NAME} ${GTK3_LIBRARIES})

References :

http://stackoverflow.com/questions/27514291/how-to-add-compiler-arguments-using-cmake