LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-24-2011, 03:21 AM   #1
ajschaeffer
LQ Newbie
 
Registered: Oct 2011
Posts: 3

Rep: Reputation: Disabled
CMake Strange "Install" behaviour with home-grown software [Linux x86_64, CMake 2.8]


Hi,

I have some home-grown software that I am trying to compile using CMake. I have included the CMakeLists.txt file below. First let me summarize. The main code I am compiling is calling invA11.f. It uses two subroutine files called invA11_subs.f and pts_subs.f. It also uses two modules. The first is called compile_info.F90, which contains variables identifying the program version, host, and the computer on which the code was compiled (these values are set with pre-processing). The second module is called inv_dims.F90. This module is also pre-processed, and defines the array dimensions of the main variables in the invA11.f program.

I need to have several different versions of this program with different Memory footprints, so I have pre-processor statements in inv_dims.F90 that select different preset memory dimenions depending on the pre-processor -D flag. The array dimension is then included in the name of the executable (ie, invA11_1.5b instead of just invA11).

The current CMakeLists file generates a copy of the inv_dims.F90 file for each desired memory dimension (is copied to inv_dims_M1p5b.F90 for example), then each executable is compiled. The main program invA11.f writes out a summary of the compile date/time, host, version, and memory dimensions as it begins to run.

The CMakeLists.txt file half works. After running cmake, I can then run "make". This compiles all the software without any problems. I can run the executables, and the summary each one displays (array dimensions) correctly reflects the executable name.

The Problem: after running "make", I then run "make install". Rather than just checking each target is built, it remakes all the targets, then installs them in the selected bin dir. However, all the of executables now have the array dimesions of the last target compiled. For example, the versions compiled previously using inv_dims_M1p5b.F90 and inv_dims_M4p0b.F90 now appear to have been compiled using inv_dims_M6p2b.F90. I don't understand where this problem is coming from, because if I don't run "make install", and just "make", then everything is compiled correctly. Any insight would be greatly appreciated. This is my first CMake project, so I'm learning it at the same time.

EDIT: One further point. Every time I run make, despite whether I made any changes to source code or not, I get warnings about modification times of Makefiles being 3000 seconds in the future. Both CMAKE and Make are run on the same computer within 1 minute of each other. Also, some further detail on how it fails compiling.
The following sequence results in executables that do not have the correct dimensions:
make
make install
However, this sequene is ok:
make
make clean
make install
It seems that it fails if there are any files left over from the previous compilation.

Thanks!

------------------------ CMakeLists.txt ----------------------------
Code:
PROJECT(Inv Fortran)
cmake_minimum_required(VERSION 2.6)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)

set(CMAKE_BUILD_TYPE "Release")

#-- set install directory
if(NOT ${PREFIX})
  set(CMAKE_INSTALL_PREFIX "${PREFIX}")
else(NOT ${PREFIX})
  set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}")
endif(NOT ${PREFIX})

#-- Determine Compilation Date/time
EXECUTE_PROCESS(COMMAND date +%d-%b-%Y_%H:%M
    TIMEOUT 5
    RESULT_VARIABLE DATE_RES
    OUTPUT_VARIABLE DATETIME
    ERROR_VARIABLE  DATE_ERR
    OUTPUT_STRIP_TRAILING_WHITESPACE)

#-- Determine Host
EXECUTE_PROCESS(COMMAND hostname
    TIMEOUT 5
    RESULT_VARIABLE HOST_RES
    OUTPUT_VARIABLE HOSTCOMP
    ERROR_VARIABLE  HOST_ERR
    OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REGEX REPLACE "\\.[a-zA-Z0-9]*" "" HOSTCOMP "${HOSTCOMP}")

#-- Version Info
set(VERSION_MAJOR "3")
set(VERSION_MINOR "0")
set(VERSION_PATCH "1")

#-- Code Description
set(DESCRITION "Inv Main Codes")

#-- Generate copies of module file that initializes the dimensions of the main variables of invA11.f
set(MemSetInt4 M1p5b M2p1b M3p4b M3p7b M4p0b M5p0b M6p2b)
foreach(mem ${MemSetInt4})
  ADD_CUSTOM_COMMAND(
     OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/inv_dims_${mem}.F90
     COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/include/inv_dims.F90 ${CMAKE_CURRENT_BINARY_DIR}/inv_dims_${mem}.F90
     DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/include/inv_dims.F90
   )
  set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/inv_dims_${mem}.F90 PROPERTIES COMPILE_FLAGS "-D${mem} -fno-range-check")
endforeach(mem ${MemSetInt4})
#-------------------------------------------------------------#


#-- set source file compile flags
set_source_files_properties(invA11.f include/invA11_subs.f include/pts_subs.f PROPERTIES COMPILE_FLAGS "-mcmodel=large -fno-automatic -finit-local-zero -frecord-marker=8")
set_source_files_properties(compile_info.F90 PROPERTIES COMPILE_FLAGS "-D__CVERSION=\\\"${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}\\\" -D__CDATETIME=\\\"${DATETIME}\\\" -D__CHOST=\\\"${HOSTCOMP}\\\" ")
#-------------------------------------------------------------#


#-------------------------------------------------------------#
  #-- Inversions
  set(MemSetInt4Triton M1p5b M2p1b M3p4b M3p7b M4p0b)
  foreach(MemSet ${MemSetInt4Triton})
    string(REGEX REPLACE "^M" "" exectag "${MemSet}")
    string(REGEX REPLACE "p" "." exectag "${exectag}")
    add_executable(invA11_${exectag} ${CMAKE_CURRENT_BINARY_DIR}/inv_dims_${MemSet}.F90 compile_info.F90 include/invA11_subs.f include/pts_subs.f invA11.f)
    install(TARGETS invA11_${exectag} RUNTIME DESTINATION bin)
  endforeach(MemSet ${MemSetInt4Triton})

Last edited by ajschaeffer; 10-24-2011 at 04:07 AM. Reason: A few new observations
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cmake: Using find_package(Boost) when FindBoost.cmake is not in the default location damien_d Programming 3 10-27-2010 03:40 PM
seeking "sound effects" for my home-grown video SaintDanBert Linux - Software 2 07-06-2010 05:12 PM
using cmake: "could not find qtglobal header". Issue with qt4? perturbed Linux - Newbie 1 01-20-2009 01:38 PM
"qmake not found!" -- Qt-4.3.4 is installed, so what must I set to point cmake to it? analgesic Slackware 10 03-12-2008 09:02 PM
Compiling stellarium: cmake returns "CURL was not found" charlesreid1 Linux - Software 2 10-23-2007 12:02 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration