# --- INTERNAL STUFF --- cmake_minimum_required(VERSION 3.1.0) if (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/config.h") configure_file(config.h.in "${CMAKE_CURRENT_SOURCE_DIR}/config.h") endif() configure_file(quick-text-bar.1.in quick-text-bar.1) include(config.cmake.default) include(config.cmake OPTIONAL) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_C_STANDARD 99) set(THREADS_PREFER_PTHREAD_FLAG ON) include(GNUInstallDirs) project(quick-text-bar) if(EXTRA_FLAGS) list(JOIN EXTRA_FLAGS " " EXTRA_FLAGS_STRING) message("Building with extra flags: ${EXTRA_FLAGS_STRING}") endif() find_package(Threads REQUIRED) find_package(PkgConfig REQUIRED) if(EXTRA_PACKAGES) pkg_check_modules(USER REQUIRED ${EXTRA_PACKAGES}) include_directories(${USER_INCLUDE_DIRS}) link_directories(${USER_LIBRARY_DIRS}) add_definitions(${USER_CFLAGS_OTHER}) list(APPEND EXTRA_LIBRARIES ${USER_LIBRARIES}) endif() if(USE_X) pkg_check_modules(X11 REQUIRED x11) include_directories(${X11_INCLUDE_DIRS}) link_directories(${X11_LIBRARY_DIRS}) add_definitions(${X11_CFLAGS_OTHER}) add_compile_definitions(HAS_X11) list(APPEND EXTRA_LIBRARIES ${X11_LIBRARIES}) endif() list(LENGTH MODULE_NAMES MODULE_COUNT) if(MODULE_COUNT EQUAL 0) message(FATAL_ERROR "No modules defined!") endif() foreach(module_name ${MODULE_NAMES}) string(FIND "${module_name}" "/" sep_index) if(NOT sep_index EQUAL -1) set(module_path "${module_name}") else() set(module_path "${MODULE_DIRECTORY}${module_name}") endif() message("Found module: ${module_path}") list(APPEND MODULE_SOURCE_FILES "${module_path}") endforeach() add_compile_definitions(QTB_VERSION="${QTB_VERSION}") add_definitions(${EXTRA_FLAGS}) add_executable(quick-text-bar main.c ${MODULE_SOURCE_FILES} ${EXTRA_SOURCE_FILES}) target_link_libraries(quick-text-bar PRIVATE Threads::Threads m ${EXTRA_LIBRARIES}) install(TARGETS quick-text-bar) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/quick-text-bar.1" DESTINATION "${CMAKE_INSTALL_MANDIR}/man1")