[Insight-developers] CMake TRY_COMPILE help

Andy Cedilnik andy.cedilnik at kitware.com
Fri Jul 2 15:50:36 EDT 2004


Hi Hans,

Could you copy TestBigEndian.cmake from CMake/Modules and modify it to
do your test. There are couple of problems with your test, also I
personally do not like these generic tests to be in the CMakeLists.txt
files.

Also, we know that that one works.

Then you do something like:

INCLUDE(${ITK_SOURCE_DIR}/CMake/TestIDynamic.cmake)
TEST_I_DYNAMIC(INTEL_COMPILER_NO_I_DYNAMIC)
IF("${INTEL_COMPILER_NO_I_DYNAMIC}")
  SET(ITK_REQUIRED_CXX_FLAGS "${ITK_REQUIRED_CXX_FLAGS}")
ELSE("${INTEL_COMPILER_NO_I_DYNAMIC}")
  SET(ITK_REQUIRED_CXX_FLAGS "${ITK_REQUIRED_CXX_FLAGS} -i_dynamic")
ENDIF("${INTEL_COMPILER_NO_I_DYNAMIC}")

			Andy

On Fri, 2004-07-02 at 15:40, Hans Johnson wrote:
> I've just submitted a modification to the main CMakeList.txt file for
> ITK.  I was hoping that this would make the build smarter for when to
> include/exclude the -i_dynamic flag under the intel compiler.
> 
> IF(UNIX)
>   TRY_COMPILE(INTEL_COMPILER_NO_I_DYNAMIC ${ITK_BINARY_DIR}
> ${ITK_SOURCE_DIR}/CMake/test_intel_requires_i_dynamic.cxx )
>   IF(INTEL_COMPILER_NO_I_DYNAMIC)
>     SET(ITK_REQUIRED_CXX_FLAGS "${ITK_REQUIRED_CXX_FLAGS}")
>   ELSE(INTEL_COMPILER_NO_I_DYNAMIC)
>     SET(ITK_REQUIRED_CXX_FLAGS "${ITK_REQUIRED_CXX_FLAGS} -i_dynamic")
>   ENDIF(INTEL_COMPILER_NO_I_DYNAMIC)
> ENDIF(UNIX)
> 
> On Intel 8 INTEL_COMPILER_NO_I_DYNAMIC should be TRUE and -i_dynamic is
> not needed
> 
> On Intel 7 (+RH9, EL-3, SUSE 9 ...) INTEL_COMPILER_NO_I_DYNAMIC should
> be FALSE and -i_dynamic is needed as a work around
> 
> Looking at the CMakeCache.txt file shows that the TRY_COMPILE is
> actually setting the INTEL_COMPILER_NO_I_DYNAMIC variable correctly ,
> but neither the IF or the ELSE part of this logic is is ever occuring.
> 
> 
> As a test I used the following code:
> 
> 
> > IF(UNIX)
> >   TRY_COMPILE(INTEL_COMPILER_NO_I_DYNAMIC ${ITK_BINARY_DIR}
> > ${ITK_SOURCE_DIR}/CMake/test_intel_requires_i_dynamic.cxx )
> >   IF(INTEL_COMPILER_NO_I_DYNAMIC)
> >     SET(ITK_REQUIRED_CXX_FLAGS "${ITK_REQUIRED_CXX_FLAGS} 
> > -FLAG_IS_TRUE_ERROR")
> >   ELSE(INTEL_COMPILER_NO_I_DYNAMIC)
> >     SET(ITK_REQUIRED_CXX_FLAGS "${ITK_REQUIRED_CXX_FLAGS}
> > -FLAG_IS_FALSE_ERROR")
> >   ENDIF(INTEL_COMPILER_NO_I_DYNAMIC)
> > ENDIF(UNIX)
> 
> and neither of the flags was added.
> 
> I am using CMake v 1.8.3




More information about the Insight-developers mailing list