[CMake] 2.4.7 TutorialStep1/TutorialStep5 test failure on Tru64 UNIX 5.1

Albert Chin cmake at mlists.thewrittenword.com
Thu Sep 20 17:55:31 EDT 2007


Both TutorialStep1 and TutorialStep5 use sqrt() and assume -lm will be
linked in. This doesn't work on Tru64 UNIX, where you need to
explicitly link with -lm. 

The attached patch works. Is it correct?

-- 
albert chin (china at thewrittenword.com)
-------------- next part --------------
Index: Tests/Tutorial/Step5/CMakeLists.txt
===================================================================
--- Tests/Tutorial/Step5/CMakeLists.txt.orig	2007-09-20 20:49:44.000000000 +0000
+++ Tests/Tutorial/Step5/CMakeLists.txt	2007-09-20 20:51:52.245192304 +0000
@@ -4,6 +4,11 @@
 set (Tutorial_VERSION_MAJOR 1)
 set (Tutorial_VERSION_MINOR 0)
 
+# Link to libm on unix for sqrt().
+IF(UNIX)
+  LINK_LIBRARIES(m)
+ENDIF(UNIX)
+
 # does this system provide the log and exp functions?
 include (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake)
 check_function_exists (log HAVE_LOG)
Index: Tests/Tutorial/Step1/CMakeLists.txt
===================================================================
--- Tests/Tutorial/Step1/CMakeLists.txt.orig	2007-09-20 21:00:08.000000000 +0000
+++ Tests/Tutorial/Step1/CMakeLists.txt	2007-09-20 21:52:30.264168550 +0000
@@ -15,5 +15,10 @@
 # so that we will find TutorialConfig.h
 include_directories("${PROJECT_BINARY_DIR}")
 
+# Link to libm on unix for sqrt().
+IF(UNIX)
+  LINK_LIBRARIES(m)
+ENDIF(UNIX)
+
 # add the executable
 add_executable(Tutorial tutorial.cxx)


More information about the CMake mailing list