2015-12-05 22:49:18 +01:00
cmake_minimum_required ( VERSION 3.1.0 FATAL_ERROR )
2015-12-08 08:33:39 +01:00
# add project files
set ( HEADER_FILES
a n g l e . h
l o c a t i o n . h
m a i n . h
u t i l s . h
)
set ( SRC_FILES
a n g l e . c p p
l o c a t i o n . c p p
m a i n . c p p
u t i l s . c p p
)
2015-12-05 22:49:18 +01:00
# meta data
set ( META_PROJECT_NAME geocoordinatecalculator )
2015-12-08 08:33:39 +01:00
set ( META_APP_NAME "Geo coordinate calculator" )
2015-12-05 22:49:18 +01:00
set ( META_APP_AUTHOR "Martchus" )
set ( META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}" )
2015-12-08 08:33:39 +01:00
set ( META_APP_DESCRIPTION "Command line tool for basic calculations with geo coordinates such as format conversions and calculation of distance, bearing, mid point, destination and more." )
2015-12-05 22:49:18 +01:00
set ( META_VERSION_MAJOR 1 )
2015-12-27 22:36:33 +01:00
set ( META_VERSION_MINOR 1 )
2016-01-21 16:33:18 +01:00
set ( META_VERSION_PATCH 1 )
2015-12-08 08:33:39 +01:00
set ( META_APP_VERSION ${ META_VERSION_MAJOR } . ${ META_VERSION_MINOR } . ${ META_VERSION_PATCH } )
2015-12-05 22:49:18 +01:00
# stringification of meta data
set ( META_PROJECT_NAME_STR "\" ${ META_PROJECT_NAME } \"")
set ( META_APP_NAME_STR "\" ${ META_APP_NAME } \"")
set ( META_APP_AUTHOR_STR "\" ${ META_APP_AUTHOR } \"")
set ( META_APP_URL_STR "\" ${ META_APP_URL } \"")
2015-12-08 08:33:39 +01:00
set ( META_APP_DESCRIPTION_STR "\" ${ META_APP_DESCRIPTION } \"")
set ( META_APP_VERSION ${ META_VERSION_MAJOR } . ${ META_VERSION_MINOR } . ${ META_VERSION_PATCH } )
set ( META_APP_VERSION_STR "\" ${ META_APP_VERSION } \"")
# define project
project ( ${ META_PROJECT_NAME } )
2015-12-05 22:49:18 +01:00
# add configuration header
2015-12-08 08:33:39 +01:00
configure_file (
" $ { P R O J E C T _ S O U R C E _ D I R } / r e s o u r c e s / c o n f i g . h . i n "
" $ { P R O J E C T _ B I N A R Y _ D I R } / r e s o u r c e s / c o n f i g . h "
2015-12-05 22:49:18 +01:00
)
include_directories ( "${PROJECT_BINARY_DIR}" )
2015-12-08 08:33:39 +01:00
# add windows resource file
if ( MINGW )
# creation windows icon from png with ffmpeg if available
find_program ( FFMPEG_BIN ffmpeg avconv )
if ( FFMPEG_BIN )
set ( PNG_ICON_PATH "${PROJECT_SOURCE_DIR}/resources/icons/hicolor/128x128/apps/${META_PROJECT_NAME}.png" )
if ( EXISTS ${ PNG_ICON_PATH } )
set ( WINDOWS_ICON_PATH "${PROJECT_BINARY_DIR}/${META_PROJECT_NAME}.ico" )
set ( WINDOWS_ICON_RC_ENTRY "IDI_ICON1 ICON DISCARDABLE \" ${ WINDOWS_ICON_PATH } \"")
add_custom_command (
O U T P U T " $ { W I N D O W S _ I C O N _ P A T H } "
C O M M A N D $ { F F M P E G _ B I N } - y - i " $ { P N G _ I C O N _ P A T H } " - v f c r o p = i w - 2 0 : i h - 2 0 : 1 0 : 1 0 , s c a l e = 6 4 : 6 4 " $ { W I N D O W S _ I C O N _ P A T H } "
)
endif ( )
endif ( FFMPEG_BIN )
# create windows rc file from template
set ( WINDOWS_EXT "exe" )
configure_file (
" $ { P R O J E C T _ S O U R C E _ D I R } / r e s o u r c e s / w i n d o w s . r c . i n "
" $ { P R O J E C T _ B I N A R Y _ D I R } / r e s o u r c e s / w i n d o w s . r c "
)
# set windres as resource compiler
set ( RES_FILES "${PROJECT_BINARY_DIR}/resources/windows.rc" )
set ( CMAKE_RC_COMPILER_INIT windres )
set ( CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>" )
enable_language ( RC )
endif ( MINGW )
2015-12-05 22:49:18 +01:00
2015-12-15 23:33:24 +01:00
# disable new ABI (can't catch ios_base::failure with new ABI)
add_definitions (
- D _ G L I B C X X _ U S E _ C X X 1 1 _ A B I = 0
)
2015-12-05 22:49:18 +01:00
# executable and linking
2015-12-08 08:33:39 +01:00
add_executable ( ${ META_PROJECT_NAME } ${ HEADER_FILES } ${ SRC_FILES } ${ RES_FILES } ${ WINDOWS_ICON_PATH } )
2015-12-05 22:49:18 +01:00
target_link_libraries ( ${ META_PROJECT_NAME } c++utilities )
2015-12-08 08:33:39 +01:00
set_target_properties ( ${ META_PROJECT_NAME } PROPERTIES
C X X _ S T A N D A R D 1 1
)
2015-12-05 22:49:18 +01:00
# add install target
2015-12-08 08:33:39 +01:00
install ( TARGETS ${ META_PROJECT_NAME }
R U N T I M E D E S T I N A T I O N b i n
C O M P O N E N T b i n a r y
)
2016-01-21 16:33:18 +01:00
if ( NOT TARGET install-binary )
add_custom_target ( install-binary
D E P E N D S $ { M E T A _ P R O J E C T _ N A M E }
C O M M A N D " $ { C M A K E _ C O M M A N D } " - D C M A K E _ I N S T A L L _ C O M P O N E N T = b i n a r y - P " $ { C M A K E _ B I N A R Y _ D I R } / c m a k e _ i n s t a l l . c m a k e "
)
endif ( )
if ( NOT TARGET install-mingw-w64 )
add_custom_target ( install-mingw-w64
D E P E N D S i n s t a l l - b i n a r y
)
endif ( )
if ( NOT TARGET install-binary-strip )
add_custom_target ( install-binary-strip
D E P E N D S $ { M E T A _ P R O J E C T _ N A M E }
C O M M A N D " $ { C M A K E _ C O M M A N D } " - D C M A K E _ I N S T A L L _ D O _ S T R I P = 1 - D C M A K E _ I N S T A L L _ C O M P O N E N T = b i n a r y - P " $ { C M A K E _ B I N A R Y _ D I R } / c m a k e _ i n s t a l l . c m a k e "
)
endif ( )
if ( NOT TARGET install-mingw-w64-strip )
add_custom_target ( install-mingw-w64-strip
D E P E N D S i n s t a l l - b i n a r y - s t r i p
)
endif ( )
2015-12-08 08:33:39 +01:00