From 414b807f92a7818c673d85e7dc829573805a6e7b Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 22 Jan 2013 20:40:25 +0000 Subject: [PATCH] Using CMake to set the program version. This is an example of how a CMake variable can be used inside the C++ code without breaking anything. git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@326 64b25241-fba3-4117-9849-534c7e92360d --- CMakeLists.txt | 11 +++-------- src/main/main.cc | 7 +++++-- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 455e1095f..494c7240e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ ######################################################################## if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) - message(FATAL_ERROR "Prevented in-tree build. This is bad practice.") + message(FATAL_ERROR "Prevented in-tree build. This is bad practice. Try 'cd build && cmake ../' ") endif(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) ######################################################################## @@ -119,9 +119,6 @@ if(NOT GNURADIO_CORE_FOUND) message(FATAL_ERROR "Please install GNU Radio and all its dependencies. Visit http://gnuradio.org") endif(NOT GNURADIO_CORE_FOUND) - - - find_package(Gruel) if(NOT GRUEL_FOUND) message(FATAL_ERROR "Gruel required to build gnss-sdr") @@ -129,10 +126,6 @@ endif() link_libraries(gruel) include_directories(${GRUEL_INCLUDE_DIRS}) - - - - find_package(UHD) if(NOT UHD_FOUND) message(FATAL_ERROR "UHD required to build gnss-sdr") @@ -481,6 +474,8 @@ endif( CMAKE_SIZEOF_VOID_P EQUAL 8 ) list(APPEND CMAKE_CXX_FLAGS ${MY_CXX_FLAGS}) +add_definitions( -DGNSS_SDR_VERSION="${VERSION}" ) + ######################################################################## # Add subdirectories (in order of deps) ######################################################################## diff --git a/src/main/main.cc b/src/main/main.cc index b34ed8fb0..a4f7ac5ad 100644 --- a/src/main/main.cc +++ b/src/main/main.cc @@ -8,7 +8,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2012 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2013 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -30,6 +30,9 @@ * * ------------------------------------------------------------------------- */ +#ifndef GNSS_SDR_VERSION +#define GNSS_SDR_VERSION "0.0.1" +#endif #include #include @@ -73,7 +76,7 @@ int main(int argc, char** argv) google::SetUsageMessage(intro_help); - google::SetVersionString("0.1"); + google::SetVersionString(GNSS_SDR_VERSION); google::ParseCommandLineFlags(&argc, &argv, true); std::cout << "Initializing GNSS-SDR... Please wait." << std::endl;