|
|
|
|
3
|
project( "slop" )
|
3
|
project( "slop" )
|
4
|
set( slop_VERSION_MAJOR 3 )
|
4
|
set( slop_VERSION_MAJOR 3 )
|
5
|
set( slop_VERSION_MINOR 1 )
|
5
|
set( slop_VERSION_MINOR 1 )
|
6
|
-set( slop_VERSION_PATCH 12 )
|
|
|
|
|
6
|
+set( slop_VERSION_PATCH 13 )
|
7
|
|
7
|
|
8
|
set( BIN_TARGET "${PROJECT_NAME}" )
|
8
|
set( BIN_TARGET "${PROJECT_NAME}" )
|
9
|
set( CMAKE_INSTALL_PREFIX "/usr/bin" )
|
9
|
set( CMAKE_INSTALL_PREFIX "/usr/bin" )
|
|
|
|
|
35
|
# so nobody has to go find and install gengetopt if they don't want to.
|
35
|
# so nobody has to go find and install gengetopt if they don't want to.
|
36
|
find_program( GENGETOPT_EXECUTABLE gengetopt
|
36
|
find_program( GENGETOPT_EXECUTABLE gengetopt
|
37
|
DOC "A tool to generate code to grab command line options." )
|
37
|
DOC "A tool to generate code to grab command line options." )
|
38
|
-find_program( SED_EXECUTABLE sed
|
|
|
39
|
- DOC "A text replacement tool used to help generate code" )
|
|
|
40
|
-find_program( COPY_EXECUTABLE cp )
|
|
|
41
|
-if ( GENGETOPT_EXECUTABLE AND SED_EXECUTABLE AND COPY_EXECUTABLE )
|
|
|
42
|
- message( "Executing " "${GENGETOPT_EXECUTABLE}" " " "--input=options.ggo" " " "--header-extension=in" )
|
|
|
43
|
- execute_process( COMMAND
|
|
|
44
|
- "${GENGETOPT_EXECUTABLE}" "--input=options.ggo"
|
|
|
45
|
- WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src" )
|
|
|
46
|
- execute_process( COMMAND
|
|
|
47
|
- "${COPY_EXECUTABLE}" "cmdline.h" "cmdline.in"
|
|
|
|
|
38
|
+find_program( SED_EXECUTABLE sed )
|
|
|
39
|
+if ( GENGETOPT_EXECUTABLE AND SED_EXECUTABLE )
|
|
|
40
|
+ message( "-- Regenerating cmdline.in" )
|
|
|
41
|
+ # gengetopt generates cmdline.h, then we move it to cmdline.in.
|
|
|
42
|
+ execute_process( COMMAND "${GENGETOPT_EXECUTABLE}" "--input=options.ggo"
|
48
|
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src" )
|
43
|
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src" )
|
|
|
44
|
+ file( RENAME "${CMAKE_CURRENT_SOURCE_DIR}/src/cmdline.h" "${CMAKE_CURRENT_SOURCE_DIR}/src/cmdline.in" )
|
49
|
# Due to a bug in gengetopt, we have to manually insert some code.
|
45
|
# Due to a bug in gengetopt, we have to manually insert some code.
|
50
|
# Replace the first instance of REPLACEME with some text.
|
46
|
# Replace the first instance of REPLACEME with some text.
|
51
|
# Eight backslashes = two in the code because of how many instances of escaping is happening.
|
47
|
# Eight backslashes = two in the code because of how many instances of escaping is happening.
|
52
|
- message( "Replacing REPLACEME in generated code..." )
|
|
|
53
|
- execute_process( COMMAND
|
|
|
54
|
- "${SED_EXECUTABLE}" "-i" "0,/REPLACEME/{s/REPLACEME/X=%x\\\\\\\\nY=%y\\\\\\\\nW=%w\\\\\\\\nH=%h\\\\\\\\nG=%g\\\\\\\\nID=%i\\\\\\\\nCancel=%c\\\\\\\\n/}" "cmdline.c"
|
|
|
|
|
48
|
+ execute_process( COMMAND "${SED_EXECUTABLE}" "-i" "0,/REPLACEME/{s/REPLACEME/X=%x\\\\\\\\nY=%y\\\\\\\\nW=%w\\\\\\\\nH=%h\\\\\\\\nG=%g\\\\\\\\nID=%i\\\\\\\\nCancel=%c\\\\\\\\n/}" "cmdline.c"
|
55
|
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src" )
|
49
|
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src" )
|
56
|
# Then replace remaining instances.
|
50
|
# Then replace remaining instances.
|
57
|
- execute_process( COMMAND
|
|
|
58
|
- "${SED_EXECUTABLE}" "-i" "s/REPLACEME/X=%x\\\\nY=%y\\\\nW=%w\\\\nH=%h\\\\nG=%g\\\\nID=%i\\\\nCancel=%c\\\\n/" "cmdline.c"
|
|
|
|
|
51
|
+ execute_process( COMMAND "${SED_EXECUTABLE}" "-i" "s/REPLACEME/X=%x\\\\nY=%y\\\\nW=%w\\\\nH=%h\\\\nG=%g\\\\nID=%i\\\\nCancel=%c\\\\n/" "cmdline.c"
|
59
|
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src" )
|
52
|
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src" )
|
60
|
else()
|
53
|
else()
|
61
|
- message( "Command gengetopt or sed not found! Won't regenerate command line code." )
|
|
|
|
|
54
|
+ message( "Warning: Command gengetopt or sed not found! Won't regenerate command line code. (If you're just compiling this doesn't matter.)" )
|
62
|
endif()
|
55
|
endif()
|
63
|
|
56
|
|
64
|
# By default our src/options.ggo has our cmake versions variables for
|
57
|
# By default our src/options.ggo has our cmake versions variables for
|
|
|
|
|
66
|
configure_file( "src/cmdline.in"
|
59
|
configure_file( "src/cmdline.in"
|
67
|
"src/cmdline.h" )
|
60
|
"src/cmdline.h" )
|
68
|
|
61
|
|
69
|
-# Here we need to make sure our README has the correct version inside of it.
|
|
|
70
|
-# We use a simple regex search and replace for it, but it seems really
|
|
|
71
|
-# hard because cmake is silly.
|
|
|
72
|
-# I think this is better than using configure_file since README.md needs
|
|
|
73
|
-# to exist within github, rather than as an input file with a different
|
|
|
74
|
-# name or extension.
|
|
|
75
|
-message( "Replacing version in readme..." )
|
|
|
76
|
-set( SEARCH_REGEX "slop v([0-9]+)\\.([0-9]+)\\.([0-9]+)" )
|
|
|
77
|
-set( REPLACE_TEXT "slop v${slop_VERSION_MAJOR}.${slop_VERSION_MINOR}.${slop_VERSION_PATCH}" )
|
|
|
78
|
-file( READ "${CMAKE_CURRENT_SOURCE_DIR}/README.md" FILE_CONTENT )
|
|
|
79
|
-string( REGEX REPLACE "${SEARCH_REGEX}" "${REPLACE_TEXT}"
|
|
|
80
|
- MODIFIED_FILE_CONTENT "${FILE_CONTENT}" )
|
|
|
81
|
-file( WRITE "${CMAKE_CURRENT_SOURCE_DIR}/README.md" "${MODIFIED_FILE_CONTENT}" )
|
|
|
|
|
62
|
+# This allows for "make README.md" to be ran to update the README's help
|
|
|
63
|
+# section automatically. We don't add it to ALL because running arbitrary
|
|
|
64
|
+# scripts is unsafe and I don't know if systems will actually have it
|
|
|
65
|
+# be executbable.
|
|
|
66
|
+add_custom_target( README.md "./generateReadme.sh" DEPENDS "slop" )
|
82
|
|
67
|
|
83
|
# Sources
|
68
|
# Sources
|
84
|
set( source
|
69
|
set( source
|
|
|
|
|
91
|
set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmakemodules" )
|
76
|
set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmakemodules" )
|
92
|
find_package( X11 REQUIRED )
|
77
|
find_package( X11 REQUIRED )
|
93
|
find_package( XExt REQUIRED )
|
78
|
find_package( XExt REQUIRED )
|
94
|
-find_package( RT REQUIRED )
|
|
|
|
|
79
|
+# This library is needed only for Ubuntu it seems, some platforms don't even
|
|
|
80
|
+# ship with it. I couldn't find a way to do a test compile to check if librt
|
|
|
81
|
+# was needed, so instead I just didn't mark it as REQUIRED.
|
|
|
82
|
+find_package( RT )
|
95
|
|
83
|
|
96
|
set( CMAKE_CXX_FLAGS
|
84
|
set( CMAKE_CXX_FLAGS
|
97
|
"${CMAKE_CXX_FLAGS} ${CMAKE_IMLIB2_CXX_FLAGS}" )
|
85
|
"${CMAKE_CXX_FLAGS} ${CMAKE_IMLIB2_CXX_FLAGS}" )
|