cmake_minimum_required(VERSION 3.10) include(CMakePushCheckState) include(CheckIncludeFile) ## Git version find_program(GIT_EXE git) if(EXISTS ${GIT_EXE}) execute_process(COMMAND ${GIT_EXE} describe --dirty --always --tag WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE GIT_VERSION RESULT_VARIABLE GIT_DESCRIBE_RESULT OUTPUT_STRIP_TRAILING_WHITESPACE) if(NOT ${GIT_DESCRIBE_RESULT} EQUAL 0) set(GIT_VERSION unknown) endif(NOT ${GIT_DESCRIBE_RESULT} EQUAL 0) else(EXISTS ${GIT_EXE}) set(GIT_VERSION unknown) endif(EXISTS ${GIT_EXE}) # set the project name project(Magicard-CUPS-driver DESCRIPTION "CUPS driver for Magicard Printers" HOMEPAGE_URL "http://www.magicard.com" LANGUAGES C) ## Configure CUPS # https://github.com/pdewacht/brlaser/blob/master/CMakeLists.txt find_program(CUPS_CONFIG NAMES cups-config) if(NOT CUPS_CONFIG) message(FATAL_ERROR "cups-config command not found. Are the CUPS development packages installed?") endif() if(NOT CUPS_DATA_DIR) execute_process( COMMAND "${CUPS_CONFIG}" --datadir OUTPUT_VARIABLE CUPS_DATA_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) endif() if(NOT CUPS_SERVER_BIN) execute_process( COMMAND "${CUPS_CONFIG}" --serverbin OUTPUT_VARIABLE CUPS_SERVER_BIN OUTPUT_STRIP_TRAILING_WHITESPACE) endif() if(NOT CUPS_CFLAGS) execute_process( COMMAND "${CUPS_CONFIG}" --cflags OUTPUT_VARIABLE CUPS_CFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE) endif() if(NOT CUPS_LDFLAGS) execute_process( COMMAND "${CUPS_CONFIG}" --ldflags OUTPUT_VARIABLE CUPS_LDFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE) endif() if(NOT CUPS_LIBS) execute_process( COMMAND "${CUPS_CONFIG}" --image --libs OUTPUT_VARIABLE CUPS_LIBS OUTPUT_STRIP_TRAILING_WHITESPACE) endif() cmake_push_check_state() set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${CUPS_CFLAGS}") check_include_file(cups/raster.h HAVE_CUPS_RASTER_H) cmake_pop_check_state() if(NOT HAVE_CUPS_RASTER_H) message(SEND_ERROR " header not found. Are the CUPS development packages installed?") endif() #add_subdirectory(src) set (PROJ_BUILD_FLAGS "\ -Wall \ -Wextra \ -Wpedantic \ -Werror \ -Wno-error=deprecated \ -Wno-error=deprecated-declarations \ -fPIC \ ") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG") set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PROJ_BUILD_FLAGS}") # add the executable add_executable(rastertoultra src/rastertoultra.c src/colour-profiles/magiox.c src/colour-profiles/magir2x.c src/colour-profiles/magiry.c src/colrmtch.c src/crc32.c src/magencd.c src/rp2mag.c src/utils.c src/rp2mag_encode.c src/command_helper.c src/commandmb1.c) target_compile_options(rastertoultra PRIVATE ${CUPS_CFLAGS}) target_link_libraries(rastertoultra ${CUPS_LIBS}) target_link_libraries(rastertoultra ${CUPS_LDFLAGS}) target_link_libraries(rastertoultra m) add_executable(cmdtoultra src/cmdtoultra.c src/crc32.c) target_link_libraries(cmdtoultra PRIVATE ${CUPS_LIBS}) ## INSTALL file(GLOB PPD_FILES LIST_DIRECTORIES false ppd/*.ppd) install( TARGETS rastertoultra cmdtoultra DESTINATION "${CUPS_SERVER_BIN}/filter") install(FILES ${PPD_FILES} DESTINATION "${CUPS_DATA_DIR}/model/ultra") ## Package set(CPACK_PACKAGE_VERSION "${GIT_VERSION}") if (APPLE) set(CPACK_GENERATOR "productbuild") else() # DEB set(CPACK_GENERATOR "DEB") set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Magicard Ltd") endif() # Source TGZ # TODO: This isn't yet complete. set(CPACK_SOURCE_GENERATOR "TGZ") set(CPACK_SOURCE_IGNORE_FILES .clang-format \\.git/ .gitmodules .gitignore .vim/ ".*~$" ".*\.cmake$" /bin/ /build/ /build_temp/ /build_tools/ /CMakeFiles/ /_CPack_Packages/ /deb/ /debian/ /install/ /output/ bitbucket-pipelines.yml CMakeCache.txt cmdtoultra install_manifest.txt jenkinsfile Makefile rastertoultra readme.md "Magicard-CUPS-driver-.*-Source.*" ".*\.deb" ) set(CPACK_VERBATIM_VARIABLES YES) include(CPack) ## TESTS #add_subdirectory(test/unity EXCLUDE_FROM_ALL) #add_executable(test_rp2_mag EXCLUDE_FROM_ALL test/test_rp2_mag.c # src/rp2mag.c # src/rp2mag_encode.c # src/utils.c) #target_compile_definitions(test_rp2_mag PRIVATE TEST) #target_include_directories(test_rp2_mag PRIVATE src) #target_link_libraries(test_rp2_mag unity) # #add_executable(test_dpi EXCLUDE_FROM_ALL test/test_dpi.c # src/rastertoultra.c # src/utils.c # src/crc32.c # src/rp2mag.c # src/colrmtch.c # src/rp2mag_encode.c # src/magencd.c # src/colour-profiles/magir2x.c # src/colour-profiles/magiox.c # src/colour-profiles/magiry.c) #target_include_directories(test_dpi PRIVATE src) #target_compile_definitions(test_dpi PRIVATE TEST) #target_compile_options(test_dpi PRIVATE -Wno-unused-function) #target_link_libraries(test_dpi unity m ${CUPS_LIBS}) # #enable_testing() #add_test(test_rp2_mag test_rp2_mag) #add_test(test_dpi test_dpi) # ## Autotools-style "make check" command #add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}) #add_dependencies(check test_rp2_mag test_dpi)