@ -1,7 +1,21 @@
cmake_minimum_required ( VERSION 3.12 )
# s e t d e f a u l t b u i l d t y p e t o Release ( if nothing else provided from outside yet )
IF ( NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES )
SET ( CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE )
set_property ( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
" M i n S i z e R e l " " R e l W i t h D e b I n f o " )
ENDIF ( )
project ( rastertozj C )
# set ( CMAKE_INSTALL_PREFIX "/usr" CACHE FILEPATH "force install to /usr" FORCE )
function ( DIAG VARR )
message ( STATUS "${VARR} -> ${${VARR}}" )
endfunction ( )
# b u i l d t h e f i l t e r b i n a r y
find_package ( Cups REQUIRED )
find_library ( CUPSIMAGELIB NAMES cupsimage )
mark_as_advanced ( CUPSIMAGELIB )
@ -10,7 +24,7 @@ set ( DEBUGFILE "/tmp/debugraster.txt" CACHE STRING "File where to make debug ou
option ( DEBUGP "Whetner to output debug info" ON )
add_executable ( rastertozj rastertozj.c )
target_compile_options ( rastertozj PRIVATE -Wall -fPIC -O3 )
target_compile_options ( rastertozj PRIVATE -Wall -fPIC )
target_include_directories ( rastertozj PRIVATE ${ CUPS_INCLUDE_DIR } )
target_link_libraries ( rastertozj PRIVATE ${ CUPS_LIBRARIES } ${ CUPSIMAGELIB } )
@ -18,4 +32,43 @@ if ( DEBUGP )
target_compile_definitions ( rastertozj PRIVATE DEBUGP DEBUGFILE= "${DEBUGFILE}" )
endif ( )
# b u i l d p p d s
if ( NOT DEFINED PPDC )
find_program ( PPDC ppdc )
endif ( )
mark_as_advanced ( PPDC )
if ( PPDC )
set ( ENV{LANG} c )
execute_process (
C O M M A N D " $ { P P D C } " - d " $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } " " z j - 5 8 . d r v "
W O R K I N G _ D I R E C T O R Y " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } "
R E S U L T _ V A R I A B L E r e s
O U T P U T _ V A R I A B L E _ C O N T E N T
E R R O R _ Q U I E T
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
endif ( )
# i n s t a l l a t i o n s t u f f
# t h i s o n e w o r k s i f y o u p e r f o r m ' m a k e i n s t a l l '
set ( CMAKE_INSTALL_PREFIX "/usr" CACHE FILEPATH "this is forced to /usr" FORCE )
# t h i s o n e w o r k s i f y o u p e r f o r m ' m a k e p a c k a g e ' - i t i s k i n d o f r o o t f o r a l l p a c k a g i n g
set ( CPACK_PACKAGING_INSTALL_PREFIX "/" )
include ( GNUInstallDirs )
if ( APPLE )
set ( FILTERPATH "usr/libexec/cups/filter" )
set ( PPDPATH "Library/Printers/PPDs/Contents/Resources" )
elseif ( UNIX )
set ( FILTERPATH "usr/lib/cups/filter" )
set ( PPDPATH "usr/share/cups/model/zjiang/" )
endif ( )
install ( TARGETS rastertozj DESTINATION ${ FILTERPATH } )
install ( FILES ${ CMAKE_CURRENT_BINARY_DIR } /zj58.ppd DESTINATION "${PPDPATH}" )
include ( CPack )