export LD_LIBRARY_PATH=/users/user-soft/lib64 export LD_RUN_PATH=/users/user-soft/lib64 export CXX=/users/user-soft/bin/g++ export LM_LICENSE_FILE=/users/user-soft/pgi12_2012 export FC=/users/user-soft/pgi12_2012/linux86-64/2012/bin/pgf90
./configure –prefix=/users/user-soft/usr251_Centos/ –qt-gui –qt-qmake=/usr/lib64/qt4/bin/qmake
git http://github.com/certik/qsnake.git has fortran_test example
execute_process(COMMAND python -c “import sys;print ‘%s/include/python%d.%d’ % (sys.prefix,sys.version_info[0],sys.version_info[1])” OUTPUT_VARIABLE PYTHON_INCLUDE_PATH)
cmake -DCMAKE_INSTALL_PREFIX:PATH=/home/phil/cmake /home/phil/repos/cython/qsnake/fortran_test
dry run and debugging:
/nfs/kite/home/phil/repos/advection/CMakeLists.txthi /nfs/kite/home/phil/repos/isccp /nfs/kite/home/phil/repos/jason/CMakeLists.txt /home/datatmp/phil/repos/scm15h/CMakeLists.txt
set(CMAKE_MODULE_PATH “/home/phil/cmake”)
add_executable(code.exe SRC/CIRC_JIANGNANS_WAY/OFFLINE_RAD_DRIVER.f90) target_link_libraries(code.exe circ phys random rad isccp)
set(CMAKE_Fortran_COMPILER g95) set(CMAKE_Fortran_FLAGS “-ffixed-form -d8 -fsloppy-char -ftrace=full -ffixed-form -d8 -fsloppy-char -ftrace=full -freal=nan” CACHE string “g95 flags”) set(CMAKE_Fortran_MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/include_g95) enable_language(Fortran)
set(LIBRARY_OUTPUT_PATH
FILE(GLOB files_f90 “*.f90”) LIST(REMOVE_ITEM files_f90 “${CMAKE_SOURCE_DIR}/sensor_planck_functions_test.f90”)
macro(CYTHON_ADD_MODULE name) add_custom_command( add_library(${name} MODULE ${name}.cpp ${ARGN})
install(TARGETS bright LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX})
add_custom_target(test COMMAND python ${CMAKE_SOURCE_DIR}/test_bright.py DEPENDS COMMENT “execute test_bright.py”)
http://eop-cfi.esa.int/CFI/ee_cfi_software.html
http://www.cmake.org/pipermail/cmake/2008-March/020255.html http://stackoverflow.com/questions/148570/using-pre-compiled-headers-with-cmake
if (MSVC) set_target_properties(abc PROPERTIES COMPILE_FLAGS “/Yustd.h”) set_source_files_properties(std.cpp PROPERTIES COMPILE_FLAGS “/Ycstd.h” endif(MSVC)
(intdir is intermediate directory expanded by mscv ide
MACRO(ADD_MSVC_PRECOMPILED_HEADER PrecompiledHeader PrecompiledSource SourcesVar)
IF(MSVC)
GET_FILENAME_COMPONENT(PrecompiledBasename
SET_SOURCE_FILES_PROPERTIES(
LIST(APPEND ${SourcesVar} ${PrecompiledSource}) ENDIF(MSVC) ENDMACRO(ADD_MSVC_PRECOMPILED_HEADER)
ADD_MSVC_PRECOMPILED_HEADER(“stdafx.h” “stdafx.cpp” MY_SRCS) ADD_EXECUTABLE(MyApp ${MY_SRCS})
enable_testing() add_test(NAME test_advec COMMAND python ${CMAKE_SOURCE_DIR}/doit.py ${plot_dir})
add_custom_target(cacheclean COMMAND rm -rf CMakeCache.txt DEPENDS cyread COMMENT “remove the cache file”)
> You can put the name of the list in another list, instead of its contents.
> And use a nested foreach to extract all of the contents.
>
> set(fooa 1 2 3)
> set(foob a b c)
> message(
make a new directory
run
cmake path_to_CMakeLists.txt
note that you want to specify the directory, and exclude the CMakeLists.txt file
FIND_LIBRARY(RESULT mylib.so PATHS ${CMAKE_BINARY_DIR}/res)
see /users/phil/install/netcdf-fortran-4.4-beta1/examples/F90
— fortran90
cmake_minimum_required(VERSION 2.8.8) set(CMAKE_Fortran_COMPILER gfortran) enable_language(Fortran)
set(NETCDF_BASE /users/user-soft/usr251_Centos/gfortran)
find_library(netcdf_lib NAMES netcdf PATHS
MACRO(add_bin_test prefix F)
ADD_EXECUTABLE(${prefix}_${F}
SET(CMAKE_INCLUDE_CURRENT_DIR ON) INCLUDE_DIRECTORIES(“${NETCDF_BASE}/include”)
SET(exam_F_tests simple_xy_wr simple_xy_rd sfc_pres_temp_wr sfc_pres_temp_rd pres_temp_4D_wr pres_temp_4D_rd)
FOREACH(F
SET(CLEANFILES sfc_pres_temp.nc simple_xy.nc pres_temp_4D.nc simple_nc4.nc simple_xy_nc4.nc) SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES “${CLEANFILES}”)
– C
cmake_minimum_required(VERSION 2.8.8)
set(NETCDF_BASE /users/user-soft/usr251_Centos/gfortran) find_library(netcdf_lib NAMES netcdf PATHS ${NETCDF_BASE}/lib NO_DEFAULT_PATH)
MACRO(add_bin_test prefix F)
ADD_EXECUTABLE(${prefix}_${F}
SET(CMAKE_INCLUDE_CURRENT_DIR ON) INCLUDE_DIRECTORIES(“${NETCDF_BASE}/include”)
SET(exam_C_tests simple_xy_wr simple_xy_rd sfc_pres_temp_wr sfc_pres_temp_rd pres_temp_4D_wr pres_temp_4D_rd)
FOREACH(F
SET(CLEANFILES sfc_pres_temp.nc simple_xy.nc pres_temp_4D.nc simple_nc4.nc simple_xy_nc4.nc) SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES “${CLEANFILES}”)
----------- building hist2d
project(fasthist)
cmake_minimum_required(VERSION 2.8)
message(“system is ${CMAKE_SYSTEM_NAME}”)
set(homedir
include_directories(${PYTHON_INCLUDE_PATH} ${NUMPY_INCLUDE_PATH}
set(CYTHON_CXX_EXTENSION “cxx”)
find_package(PythonLibs REQUIRED) find_package(Numpy REQUIRED) find_package(PyInclude REQUIRED) include_directories(${TRUE_PYTHON_INC} ${NUMPY_INCLUDE_PATH} ${fasthist_SOURCE_DIR}})
cython_add_module(fasthist fasthist.pyx)
set_target_properties(fasthist PROPERTIES PREFIX “”) install(TARGETS fasthist LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX})
add_custom_target(test COMMAND ${PYTHON_EXECUTABLE} ${fasthist_SOURCE_DIR}/test_hist.py fasthist ${LIBRARY_OUTPUT_PATH} DEPENDS fasthist COMMENT “execute test_hist.py”)
------------ findPyInclude.cmake
execute_process(
COMMAND
working with object files
http://www.cmake.org/Wiki/CMake/Tutorials/Object_Library
cmake –help-command get_filename_component GET_FILENAME_COMPONENT(dirname “c:/path/to/dir” NAME)
project(fortran_tests)
set(OSX True CACHE BOOL “Test”) if(OSX) message(“osx set to ${OSX}”) endif(OSX)
if (
message(“value of OSX is ${OSX}”)
message(“home is $ENV{HOME}”)
note no quotes
set(BUILD_WITH_INSTALL_RPATH TRUE) SET(CMAKE_INSTALL_RPATH ${nc_dir}/lib;${hdf_dir}/lib)