Advertisement
Patrickquinn1212

CMakeTextLists.txt

Sep 30th, 2019
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.87 KB | None | 0 0
  1.  
  2. list(APPEND CMAKE_MODULE_PATH "/home/pat/CLionProjects/GTK/Cmake Examples")
  3. include(FindPkgConfig)
  4. #Set the name and the supported language of the project
  5. # https://stackoverflow.com/questions/12344368/automatically-use-the-directory-as-the-project-name-in-cmake
  6. get_filename_component(ProjectId ${CMAKE_CURRENT_LIST_DIR} NAME)
  7. string(REPLACE " " "_" ProjectId ${ProjectId})
  8. project(${ProjectId} C CXX)
  9.  
  10. set(GCC_COVERAGE_COMPILE_FLAGS "-export-dynamic")
  11. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}" )
  12.  
  13. # Set the minimum version of cmake required to build this project
  14. cmake_minimum_required(VERSION 3.14)
  15. # Use the package PkgConfig to detect GTK+ headers/library files
  16. find_package(PkgConfig REQUIRED)
  17. pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
  18. # Setup CMake to use GTK+, tell the compiler where to look for headers
  19. # and to the linker where to look for libraries
  20. include_directories(${GTK3_INCLUDE_DIRS})
  21. message(staus "GTK3_INCLUDE_DIRS = ${GTK3_INCLUDE_DIRS}")
  22. link_directories(${GTK3_LIBRARY_DIRS})
  23. message(status " GTK3_LIBRARY_DIRS = ${GTK3_LIBRARY_DIRS}")
  24. # Add other flags to the compiler
  25. add_definitions(${GTK3_CFLAGS_OTHER})
  26.  
  27. message(status " GTK3_CFLAGS_OTHER = ${GTK3_CFLAGS_OTHER}")
  28. # Add an executable compiled from hello.c
  29. add_executable(${PROJECT_NAME} main.c)
  30. # Link the target to the GTK+ libraries
  31. target_link_libraries(${PROJECT_NAME} ${GTK3_LIBRARIES})
  32. message(status "GTK3_LIBRARIES = ${GTK3_LIBRARIES}")
  33.  
  34. # GLIB
  35. find_package(GLIB)
  36. pkg_check_modules(GLIB glib-2.0 REQUIRED)
  37. include_directories(${GLIB_INCLUDE_DIRS})
  38. target_link_libraries(${PROJECT_NAME} ${GLIB_LIBRARIES})
  39.  
  40. find_package(GMODULE2)
  41. include_directories(${GMODULE_INCLUDE_DIRS})
  42. target_link_libraries(${PROJECT_NAME} ${GMODULE_LIBRARY})
  43.  
  44. find_package(GThread)
  45. include_directories(${GThread_INCLUDE_DIRS})
  46. target_link_libraries(${PROJECT_NAME} ${GThread_LIBRARY})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement