[Kst] branches/work/kst/portto4/kst/cmake

Peter Kümmel syntheticpp at gmx.net
Sat Oct 6 09:54:25 UTC 2012


SVN commit 1319396 by kuemmel:

add dependencies for 3rd party libs

 M  +29 -10    3rdparty/CMakeLists.txt  
 M  +3 -0      modules/KstMacros.cmake  


--- branches/work/kst/portto4/kst/cmake/3rdparty/CMakeLists.txt #1319395:1319396
@@ -37,6 +37,16 @@
 	set(kst_make_program ${CMAKE_MAKE_PROGRAM})
 endif()
 
+# make dependencies visible for cmake
+# http://public.kitware.com/Bug/view.php?id=13538
+macro(kst_external_static_lib targetName name lib)
+    add_library(${targetName} STATIC IMPORTED GLOBAL)
+    set_target_properties(${targetName} PROPERTIES IMPORTED_LOCATION ${install_dir}/lib/${lib})
+    add_dependencies(${targetName} ${name})
+endmacro()
+
+
+
 # GETDATA
 set(ext_src ${build_dir}/getdata/src/getdata)
 if(WIN32)
@@ -64,7 +74,9 @@
 	set(gddeps -lbz2 -lz)
 endif()
 set(GETDATA_INCLUDEDIR ${install_dir}/include PARENT_SCOPE)
-set(GETDATA_LIBRARIES  ${install_dir}/lib/libgetdata++.a ${gddeps} ${install_dir}/lib/libgetdata.a PARENT_SCOPE)
+kst_external_static_lib(gdc_build   libgetdata libgetdata.a)
+kst_external_static_lib(gdcpp_build libgetdata libgetdata++.a)
+set(GETDATA_LIBRARIES gdc_build gdcpp_build ${gddeps} PARENT_SCOPE)
 
 
 # ZLIB needed by MATIO
@@ -74,14 +86,14 @@
 	set(ext_configure cmake ${ext_src} ${generator} -DBUILD_SHARED_LIBS=0 ${rc_compiler} ${install_prefix} ${build_type})
 	set(ext_install ${install_target})
 	set(ext_insource OFF )
-	set(zlib_library ${install_dir}/lib/libzlibstatic.a)
+		set(zlib_library libzlibstatic.a)
 	set(ext_make ${kst_make_program})
 else()
 	set(ext_url http://zlib.net/zlib-1.2.7.tar.gz)
 	set(ext_configure ${ext_src}/configure --static --prefix=${install_dir})
 	set(ext_install install)
 	set(ext_insource ON)
-	set(zlib_library ${install_dir}/lib/libz.a)
+		set(zlib_library libz.a)
 	set(ext_make ${CMAKE_MAKE_PROGRAM} CXXFLAGS=-fPIC CFLAGS=-fPIC)
 endif()
 ExternalProject_Add(zlib
@@ -93,6 +105,7 @@
 					BUILD_COMMAND ${ext_make}
 					INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} ${ext_install})
 
+kst_external_static_lib(zlib_build zlib ${zlib_library})
 
 # MATIO
 set(ext_src ${build_dir}/matio/src/matio)
@@ -125,7 +138,8 @@
 add_dependencies(matio zlib)
 
 set(MATIO_INCLUDEDIR ${install_dir}/include PARENT_SCOPE)
-set(MATIO_LIBRARIES  ${install_dir}/lib/libmatio.a ${zlib_library} PARENT_SCOPE)
+kst_external_static_lib(matio_build matio libmatio.a)
+set(MATIO_LIBRARIES matio_build zlib_build PARENT_SCOPE)
 
 
 # NETCDF
@@ -158,10 +172,11 @@
 					INSTALL_COMMAND ${ext_make} ${ext_install})
 
 set(NETCDF_INCLUDEDIR  ${install_dir}/include PARENT_SCOPE)
-set(NETCDF_LIBRARY_C   ${install_dir}/lib/libnetcdf.a PARENT_SCOPE)
-set(NETCDF_LIBRARY_CPP ${install_dir}/lib/libnetcdf_c++.a PARENT_SCOPE)
+kst_external_static_lib(netcdf_c_build netcdf libnetcdf.a)
+kst_external_static_lib(netcdf_cpp_build netcdf libnetcdf_c++.a)
+set(NETCDF_LIBRARY_C netcdf_c_build PARENT_SCOPE)
+set(NETCDF_LIBRARY_CPP netcdf_cpp_build PARENT_SCOPE)
 
-
 # CFITSIO
 set(ext_src ${build_dir}/cfitsio/src/cfitsio)
 if(WIN32)
@@ -191,10 +206,13 @@
 					BUILD_COMMAND ${ext_make}
 					INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} ${ext_install})
 
+
 set(CFITSIO_INCLUDEDIR ${install_dir}/include/cfitsio PARENT_SCOPE)
-set(CFITSIO_LIBRARIES  ${install_dir}/lib/libcfitsio.a PARENT_SCOPE)
+kst_external_static_lib(cfitsio_build cfitsio libcfitsio.a)
+set(CFITSIO_LIBRARIES cfitsio_build PARENT_SCOPE)
 
 
+
 # GSL
 set(ext_src ${build_dir}/gsl/src/gsl)
 if(WIN32)
@@ -225,10 +243,11 @@
 					INSTALL_COMMAND ${ext_make} ${ext_install})
 
 if(APPLE)
-	set(gsldeps ${install_dir}/lib/libgslcblas.a)
+		set(GSL_DEPS ${install_dir}/lib/libgslcblas.a)
 endif()
 set(GSL_INCLUDEDIR ${install_dir}/include PARENT_SCOPE)
-set(GSL_LIBRARIES  ${install_dir}/lib/libgsl.a ${gsldeps} PARENT_SCOPE)
+kst_external_static_lib(gsl_build gsl libgsl.a)
+set(GSL_LIBRARIES gsl_build ${GSL_DEPS} PARENT_SCOPE)
 
 
 
--- branches/work/kst/portto4/kst/cmake/modules/KstMacros.cmake #1319395:1319396
@@ -173,6 +173,9 @@
 	endif()
 endmacro()
 
+macro(kst_add_dependency name)
+	add_dependencies(${kst_name} ${name})
+endmacro()
 
 macro(kst_include_directories)
 	foreach(_it ${ARGV})


More information about the Kst mailing list