From 71fcd899a479ac48cddc63a5ca48959b6c41c338 Mon Sep 17 00:00:00 2001
From: Carles Fernandez <carles.fernandez@gmail.com>
Date: Fri, 20 Dec 2013 00:11:14 +0000
Subject: [PATCH] Change in cmake scripts that allows 'make' to spawn the
 provided amount of threads when armadillo, gflags or glog are downloaded and
 built 'on-the-fly'. Ideally each thread is executed on its own core/CPU, so a
 multi-core/CPU environment is used to its fullest. This fix allows
 compilation with e.g.  'make -j4"

git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@465 64b25241-fba3-4117-9849-534c7e92360d
---
 CMakeLists.txt                                    | 15 ++++++++-------
 src/algorithms/PVT/libs/CMakeLists.txt            |  4 +++-
 src/algorithms/channel/libs/CMakeLists.txt        |  1 +
 .../conditioner/adapters/CMakeLists.txt           |  1 +
 .../data_type_adapter/adapters/CMakeLists.txt     |  1 +
 .../input_filter/adapters/CMakeLists.txt          |  1 +
 .../observables/gnuradio_blocks/CMakeLists.txt    |  1 +
 .../output_filter/adapters/CMakeLists.txt         |  1 +
 .../resampler/gnuradio_blocks/CMakeLists.txt      |  1 +
 src/core/system_parameters/CMakeLists.txt         |  1 +
 10 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index a15784b3e..4c1755bef 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -274,9 +274,9 @@ set(GFlags_ROOT_DIR false)
 find_package(GFlags)
 
 if (NOT GFlags_FOUND)
-     message (" gflags library has not been found.")
-     message (" gflags will be downloaded and built automatically ")
-     message (" when doing 'make'. ")
+     message (STATUS " gflags library has not been found.")
+     message (STATUS " gflags will be downloaded and built automatically ")
+     message (STATUS " when doing 'make'. ")
      set(gflags_RELEASE 2.0 CACHE STRING "Local gflags release")
      set(gflags_MD5 "5fd4554d2ba84bf222a2fec0870d28df")
      
@@ -320,12 +320,12 @@ endif(NOT GFlags_FOUND)
 
 find_package(GLOG)
 if (NOT GLOG_FOUND OR LOCAL_GFLAGS)
-     message (" glog library has not been found")
+     message (STATUS " glog library has not been found")
      if(NOT GFlags_FOUND)
-          message(" or it is likely not linked to gflags.")
+          message(STATUS " or it is likely not linked to gflags.")
      endif(NOT GFlags_FOUND)
-     message (" glog will be downloaded and built automatically ")
-     message (" when doing 'make'. ")
+     message (STATUS " glog will be downloaded and built automatically ")
+     message (STATUS " when doing 'make'. ")
      set(glog_RELEASE 0.3.3)
      set(glog_MD5 "a6fd2c22f8996846e34c763422717c18")
      if(LOCAL_GFLAGS)
@@ -355,6 +355,7 @@ export LIBS=${GFlags_SHARED_LIBS}
      set(GLOG_CONFIGURE ${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE}/configure_with_gflags)   
      ExternalProject_Add(
           glog-${glog_RELEASE}
+          DEPENDS gflags-${gflags_RELEASE}
           PREFIX ${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE}
           URL http://google-glog.googlecode.com/files/glog-${glog_RELEASE}.tar.gz
           DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}/download/glog-${glog_RELEASE}
diff --git a/src/algorithms/PVT/libs/CMakeLists.txt b/src/algorithms/PVT/libs/CMakeLists.txt
index cf6ea2404..f2fd171c9 100644
--- a/src/algorithms/PVT/libs/CMakeLists.txt
+++ b/src/algorithms/PVT/libs/CMakeLists.txt
@@ -21,7 +21,8 @@ set(PVT_LIB_SOURCES
      galileo_e1_ls_pvt.cc
      kml_printer.cc
      rinex_printer.cc
-     nmea_printer.cc    
+     nmea_printer.cc  
+#     rtcm_printer.cc  
 )
 
 include_directories(
@@ -38,3 +39,4 @@ include_directories(
 
 add_library(pvt_lib ${PVT_LIB_SOURCES})
 target_link_libraries(pvt_lib ${Boost_LIBRARIES} ${GFlags_LIBS} ${GLOG_LIBRARIES} ${ARMADILLO_LIBRARIES} )
+add_dependencies(input_filter_adapters armadillo-${armadillo_RELEASE} glog-${GLOG_RELEASE})
\ No newline at end of file
diff --git a/src/algorithms/channel/libs/CMakeLists.txt b/src/algorithms/channel/libs/CMakeLists.txt
index 070d411c1..1a46cc4e4 100644
--- a/src/algorithms/channel/libs/CMakeLists.txt
+++ b/src/algorithms/channel/libs/CMakeLists.txt
@@ -31,3 +31,4 @@ include_directories(
 )
 
 add_library(channel_fsm ${CHANNEL_FSM_SOURCES})
+add_dependencies(channel_fsm glog-${GLOG_RELEASE})
\ No newline at end of file
diff --git a/src/algorithms/conditioner/adapters/CMakeLists.txt b/src/algorithms/conditioner/adapters/CMakeLists.txt
index f544da301..8ce37a37c 100644
--- a/src/algorithms/conditioner/adapters/CMakeLists.txt
+++ b/src/algorithms/conditioner/adapters/CMakeLists.txt
@@ -32,3 +32,4 @@ include_directories(
 )
 
 add_library(conditioner_adapters ${COND_ADAPTER_SOURCES})
+add_dependencies(conditioner_adapters glog-${GLOG_RELEASE})
\ No newline at end of file
diff --git a/src/algorithms/data_type_adapter/adapters/CMakeLists.txt b/src/algorithms/data_type_adapter/adapters/CMakeLists.txt
index a823bcb4f..f771ab181 100644
--- a/src/algorithms/data_type_adapter/adapters/CMakeLists.txt
+++ b/src/algorithms/data_type_adapter/adapters/CMakeLists.txt
@@ -30,3 +30,4 @@ include_directories(
 
 add_library(datatype_adapters ${DATATYPE_ADAPTER_SOURCES})
 target_link_libraries(datatype_adapters ${GNURADIO_FILTER_LIBRARIES} ${GNURADIO_BLOCKS_LIBRARIES})
+add_dependencies(datatype_adapters glog-${GLOG_RELEASE})
\ No newline at end of file
diff --git a/src/algorithms/input_filter/adapters/CMakeLists.txt b/src/algorithms/input_filter/adapters/CMakeLists.txt
index a6fb09d66..07b662af9 100644
--- a/src/algorithms/input_filter/adapters/CMakeLists.txt
+++ b/src/algorithms/input_filter/adapters/CMakeLists.txt
@@ -32,3 +32,4 @@ include_directories(
 
 add_library(input_filter_adapters ${INPUT_FILTER_ADAPTER_SOURCES})
 target_link_libraries(input_filter_adapters ${GNURADIO_RUNTIME_LIBRARIES} ${GNURADIO_BLOCKS_LIBRARIES} ${GNURADIO_FILTER_LIBRARIES})
+add_dependencies(input_filter_adapters glog-${GLOG_RELEASE})
\ No newline at end of file
diff --git a/src/algorithms/observables/gnuradio_blocks/CMakeLists.txt b/src/algorithms/observables/gnuradio_blocks/CMakeLists.txt
index 3498152dc..b87f0468d 100644
--- a/src/algorithms/observables/gnuradio_blocks/CMakeLists.txt
+++ b/src/algorithms/observables/gnuradio_blocks/CMakeLists.txt
@@ -35,3 +35,4 @@ include_directories(
 
 add_library(obs_gr_blocks ${OBS_GR_BLOCKS_SOURCES} )
 target_link_libraries(obs_gr_blocks ${GNURADIO_RUNTIME_LIBRARIES})
+add_dependencies(obs_gr_blocks glog-${GLOG_RELEASE})
\ No newline at end of file
diff --git a/src/algorithms/output_filter/adapters/CMakeLists.txt b/src/algorithms/output_filter/adapters/CMakeLists.txt
index a0c1c4890..5ea6e8385 100644
--- a/src/algorithms/output_filter/adapters/CMakeLists.txt
+++ b/src/algorithms/output_filter/adapters/CMakeLists.txt
@@ -32,3 +32,4 @@ include_directories(
 
 add_library(out_adapters ${OUTPUTFILTER_ADAPTER_SOURCES})
 target_link_libraries(out_adapters ${GNURADIO_RUNTIME_LIBRARIES} ${GNURADIO_BLOCKS_LIBRARIES})
+add_dependencies(out_adapters glog-${GLOG_RELEASE})
\ No newline at end of file
diff --git a/src/algorithms/resampler/gnuradio_blocks/CMakeLists.txt b/src/algorithms/resampler/gnuradio_blocks/CMakeLists.txt
index 1be880f29..334277eca 100644
--- a/src/algorithms/resampler/gnuradio_blocks/CMakeLists.txt
+++ b/src/algorithms/resampler/gnuradio_blocks/CMakeLists.txt
@@ -30,3 +30,4 @@ include_directories(
 )
 
 add_library(resampler_gr_blocks ${RESAMPLER_GR_BLOCKS_SOURCES})
+add_dependencies(resampler_gr_blocks glog-${GLOG_RELEASE})
\ No newline at end of file
diff --git a/src/core/system_parameters/CMakeLists.txt b/src/core/system_parameters/CMakeLists.txt
index 47458906f..a7fdb594c 100644
--- a/src/core/system_parameters/CMakeLists.txt
+++ b/src/core/system_parameters/CMakeLists.txt
@@ -50,3 +50,4 @@ link_directories(${Boost_LIBRARY_DIR})
 
 add_library(gnss_system_parameters ${SYSTEM_PARAMETERS_SOURCES})
 target_link_libraries(gnss_system_parameters ${Boost_LIBRARIES})
+add_dependencies(gnss_system_parameters glog-${GLOG_RELEASE})