From 5048acc9f9575693acb9aa862191be6ccee254c2 Mon Sep 17 00:00:00 2001 From: Maarten Billemont Date: Mon, 6 Nov 2017 18:38:36 -0500 Subject: [PATCH] cmake's find_package is case sensitive & be smarter about git. --- platform-independent/cli-c/CMakeLists.txt | 36 +++++++++++++---------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/platform-independent/cli-c/CMakeLists.txt b/platform-independent/cli-c/CMakeLists.txt index ae9b9da4..d60f280a 100644 --- a/platform-independent/cli-c/CMakeLists.txt +++ b/platform-independent/cli-c/CMakeLists.txt @@ -19,13 +19,17 @@ set( CMAKE_BUILD_TYPE Release ) set( CMAKE_C_FLAGS "-O3" ) # Version. -execute_process( COMMAND git describe --match *-clo* --long --dirty RESULT_VARIABLE status OUTPUT_VARIABLE mpw_version OUTPUT_STRIP_TRAILING_WHITESPACE ) -if( NOT status EQUAL 0 AND EXISTS "VERSION" ) +find_package( Git ) +if( GIT_FOUND ) + execute_process( COMMAND "${GIT_EXECUTABLE}" describe --match *-cli* --long --dirty + OUTPUT_VARIABLE mpw_version OUTPUT_STRIP_TRAILING_WHITESPACE ) +endif() +if( NOT mpw_version MATCHES "." ) file( READ "VERSION" mpw_version ) - string( STRIP ${mpw_version} mpw_version ) + string( STRIP "${mpw_version}" mpw_version ) endif() if( mpw_version MATCHES "." ) - add_definitions( -DMP_VERSION=${mpw_version} ) + add_definitions( "-DMP_VERSION=${mpw_version}" ) message( STATUS "Current mpw source version ${mpw_version}..." ) else() message( STATUS "Current mpw source version unknown..." ) @@ -35,8 +39,8 @@ endif() ### DEPENDENCIES function( use_mpw_sodium t r ) if( USE_SODIUM ) - target_link_libraries( ${t} sodium ) - target_compile_definitions( ${t} PUBLIC -DMPW_SODIUM=1 ) + target_link_libraries( "${t}" sodium ) + target_compile_definitions( "${t}" PUBLIC -DMPW_SODIUM=1 ) message( STATUS "${t}: USE_SODIUM is enabled." ) elseif( r STREQUAL "required" ) @@ -49,12 +53,12 @@ function( use_mpw_sodium t r ) endfunction() function( use_mpw_color t ) - find_package( CURSES ) + find_package( Curses ) if( USE_COLOR ) if ( CURSES_FOUND ) - target_include_directories( ${t} PUBLIC ${CURSES_INCLUDE_DIR} ) - target_link_libraries( ${t} ${CURSES_LIBRARIES} ) - target_compile_definitions( ${t} PUBLIC -DMPW_COLOR=1 ${CURSES_DEFINITIONS} ) + target_include_directories( "${t}" PUBLIC ${CURSES_INCLUDE_DIR} ) + target_link_libraries( "${t}" ${CURSES_LIBRARIES} ) + target_compile_definitions( "${t}" PUBLIC -DMPW_COLOR=1 ${CURSES_DEFINITIONS} ) message( STATUS "${t}: USE_COLOR is enabled." ) elseif( r STREQUAL "required" ) @@ -76,8 +80,8 @@ endfunction() function( use_mpw_json t ) if( USE_JSON ) - target_link_libraries( ${t} json-c ) - target_compile_definitions( ${t} PUBLIC -DMPW_JSON=1 ) + target_link_libraries( "${t}" json-c ) + target_compile_definitions( "${t}" PUBLIC -DMPW_JSON=1 ) message( STATUS "${t}: USE_JSON is enabled." ) elseif( r STREQUAL "required" ) @@ -90,12 +94,12 @@ function( use_mpw_json t ) endfunction() function( use_mpw_xml t r ) - find_package( LIBXML2 ) + find_package( LibXml2 ) if( USE_XML ) if ( LIBXML2_FOUND ) - target_include_directories( ${t} PUBLIC ${LIBXML2_INCLUDE_DIR} ) - target_link_libraries( ${t} ${LIBXML2_LIBRARIES} ) - target_compile_definitions( ${t} PUBLIC -DMPW_XML=1 ${LIBXML2_DEFINITIONS} ) + target_include_directories( "${t}" PUBLIC ${LIBXML2_INCLUDE_DIR} ) + target_link_libraries( "${t}" ${LIBXML2_LIBRARIES} ) + target_compile_definitions( "${t}" PUBLIC -DMPW_XML=1 ${LIBXML2_DEFINITIONS} ) message( STATUS "${t}: USE_XML is enabled." ) elseif( r STREQUAL "required" )