From 0d8f8e0021a993abe0bbdd29cba26c4be1be2885 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Tue, 22 Mar 2022 07:43:27 -0700 Subject: [PATCH] CMake: make all glcomp checks required if 'with_smyrna=ON' Given there is a build system flag `with_smyrna` that defaults to `OFF`, it seems to make more sense to unconditionally attempt to build glcomp when this flag is on. The current silent disabling behavior when dependencies are missing results in a confusing link failure when glcomp cannot be found. Following this change, this is instead a configuration failure pointing to the missing dependency(ies). --- lib/glcomp/CMakeLists.txt | 113 ++++++++++++++++++-------------------- 1 file changed, 54 insertions(+), 59 deletions(-) diff --git a/lib/glcomp/CMakeLists.txt b/lib/glcomp/CMakeLists.txt index 89ea35c84..4e221618d 100644 --- a/lib/glcomp/CMakeLists.txt +++ b/lib/glcomp/CMakeLists.txt @@ -1,66 +1,61 @@ if(with_smyrna) - find_package(Freetype) - find_package(GLUT) - find_package(GTK2 COMPONENTS gtk glade) - find_package(PANGOCAIRO) - find_package(PkgConfig) + find_package(Freetype REQUIRED) + find_package(GLUT REQUIRED) + find_package(GTK2 REQUIRED COMPONENTS gtk glade) + find_package(PANGOCAIRO REQUIRED) + find_package(PkgConfig REQUIRED) if(PKG_CONFIG_FOUND) - pkg_check_modules(XRENDER xrender) + pkg_check_modules(XRENDER REQUIRED xrender) endif() - if(Freetype_FOUND AND GLUT_FOUND AND GTK2_FOUND AND PANGOCAIRO_FOUND - AND XRENDER_FOUND) - - add_library(glcomp - glcompbutton.h - glcompdefs.h - glcompfont.h - glcompimage.h - glcomplabel.h - glcompmouse.h - glcomppanel.h - glcompset.h - glcomptextpng.h - glcomptexture.h - glpangofont.h - glutils.h - - glcompbutton.c - glcompfont.c - glcompimage.c - glcomplabel.c - glcompmouse.c - glcomppanel.c - glcompset.c - glcomptextpng.c - glcomptexture.c - glpangofont.c - glutils.c - ) - - target_include_directories(glcomp PRIVATE - ${GRAPHVIZ_LIB_DIR} - ${GRAPHVIZ_LIB_DIR}/common - ) - - target_include_directories(glcomp SYSTEM PRIVATE - ${Freetype_INCLUDE_DIRS} - ${GLUT_INCLUDE_DIRS} - ${GTK2_INCLUDE_DIRS} - ${PANGOCAIRO_INCLUDE_DIRS} - ${XRENDER_INCLUDE_DIRS} - ) - - target_link_libraries(glcomp PRIVATE - ${Freetype_LIBRARIES} - ${GLUT_LIBRARIES} - ${GTK2_LIBRARIES} - ${MATH_LIB} - ${PANGOCAIRO_LIBRARIES} - ${XRENDER_LIBRARIES} - ) - - endif() + add_library(glcomp + glcompbutton.h + glcompdefs.h + glcompfont.h + glcompimage.h + glcomplabel.h + glcompmouse.h + glcomppanel.h + glcompset.h + glcomptextpng.h + glcomptexture.h + glpangofont.h + glutils.h + + glcompbutton.c + glcompfont.c + glcompimage.c + glcomplabel.c + glcompmouse.c + glcomppanel.c + glcompset.c + glcomptextpng.c + glcomptexture.c + glpangofont.c + glutils.c + ) + + target_include_directories(glcomp PRIVATE + ${GRAPHVIZ_LIB_DIR} + ${GRAPHVIZ_LIB_DIR}/common + ) + + target_include_directories(glcomp SYSTEM PRIVATE + ${Freetype_INCLUDE_DIRS} + ${GLUT_INCLUDE_DIRS} + ${GTK2_INCLUDE_DIRS} + ${PANGOCAIRO_INCLUDE_DIRS} + ${XRENDER_INCLUDE_DIRS} + ) + + target_link_libraries(glcomp PRIVATE + ${Freetype_LIBRARIES} + ${GLUT_LIBRARIES} + ${GTK2_LIBRARIES} + ${MATH_LIB} + ${PANGOCAIRO_LIBRARIES} + ${XRENDER_LIBRARIES} + ) endif() -- 2.40.0