Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- list(APPEND CMAKE_MODULE_PATH "/home/pat/CLionProjects/GTK/Cmake Examples")
- include(FindPkgConfig)
- #Set the name and the supported language of the project
- # https://stackoverflow.com/questions/12344368/automatically-use-the-directory-as-the-project-name-in-cmake
- get_filename_component(ProjectId ${CMAKE_CURRENT_LIST_DIR} NAME)
- string(REPLACE " " "_" ProjectId ${ProjectId})
- project(${ProjectId} C CXX)
- set(GCC_COVERAGE_COMPILE_FLAGS "-export-dynamic")
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}" )
- # Set the minimum version of cmake required to build this project
- cmake_minimum_required(VERSION 3.14)
- # Use the package PkgConfig to detect GTK+ headers/library files
- find_package(PkgConfig REQUIRED)
- pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
- # Setup CMake to use GTK+, tell the compiler where to look for headers
- # and to the linker where to look for libraries
- include_directories(${GTK3_INCLUDE_DIRS})
- message(staus "GTK3_INCLUDE_DIRS = ${GTK3_INCLUDE_DIRS}")
- link_directories(${GTK3_LIBRARY_DIRS})
- message(status " GTK3_LIBRARY_DIRS = ${GTK3_LIBRARY_DIRS}")
- # Add other flags to the compiler
- add_definitions(${GTK3_CFLAGS_OTHER})
- message(status " GTK3_CFLAGS_OTHER = ${GTK3_CFLAGS_OTHER}")
- # Add an executable compiled from hello.c
- add_executable(${PROJECT_NAME} main.c)
- # Link the target to the GTK+ libraries
- target_link_libraries(${PROJECT_NAME} ${GTK3_LIBRARIES})
- message(status "GTK3_LIBRARIES = ${GTK3_LIBRARIES}")
- # GLIB
- find_package(GLIB)
- pkg_check_modules(GLIB glib-2.0 REQUIRED)
- include_directories(${GLIB_INCLUDE_DIRS})
- target_link_libraries(${PROJECT_NAME} ${GLIB_LIBRARIES})
- find_package(GMODULE2)
- include_directories(${GMODULE_INCLUDE_DIRS})
- target_link_libraries(${PROJECT_NAME} ${GMODULE_LIBRARY})
- find_package(GThread)
- include_directories(${GThread_INCLUDE_DIRS})
- target_link_libraries(${PROJECT_NAME} ${GThread_LIBRARY})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement