[CMake] PROJECT(... CXX) and CMAKE_AR

William A. Hoffman billlist at nycap.rr.com
Sat Jun 10 12:26:05 EDT 2006


At 11:47 AM 6/10/2006, Filipe Sousa wrote:
>Hi!
>
>Is there a reason for CMakeDetermineCXXCompiler.cmake not looking for
>"ar"? Without it I can't create static libraries with pure c++ projects.
>
>I attached the fix
>
>fsousa at neptuno ~ $ cmake --version
>cmake version 2.5-20060608
>-- 
>Filipe Sousa
>? CMakeDetermineCXXCompiler.cmake.diff
>Index: CMakeDetermineCXXCompiler.cmake
>===================================================================
>RCS file: /cvsroot/CMake/CMake/Modules/CMakeDetermineCXXCompiler.cmake,v
>retrieving revision 1.27
>diff -u -r1.27 CMakeDetermineCXXCompiler.cmake
>--- CMakeDetermineCXXCompiler.cmake     17 Apr 2006 17:57:34 -0000      1.27
>+++ CMakeDetermineCXXCompiler.cmake     10 Jun 2006 15:42:51 -0000
>@@ -42,6 +42,17 @@
> ENDIF(NOT CMAKE_CXX_COMPILER)
> MARK_AS_ADVANCED(CMAKE_CXX_COMPILER)
> 
>+GET_FILENAME_COMPONENT(COMPILER_LOCATION "${CMAKE_CXX_COMPILER}"
>+  PATH)
>+
>+FIND_PROGRAM(CMAKE_AR NAMES ar PATHS ${COMPILER_LOCATION} )
>+
>+FIND_PROGRAM(CMAKE_RANLIB NAMES ranlib)
>+IF(NOT CMAKE_RANLIB)
>+   SET(CMAKE_RANLIB : CACHE INTERNAL "noop for ranlib")
>+ENDIF(NOT CMAKE_RANLIB)
>+MARK_AS_ADVANCED(CMAKE_RANLIB)
>+
> # do not test for GNU if the generator is visual studio
> IF(${CMAKE_GENERATOR} MATCHES "Visual Studio")
>   SET(CMAKE_COMPILER_IS_GNUCXX_RUN 1)
>@@ -74,5 +85,6 @@
> # configure all variables set in this file
> CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CMakeCXXCompiler.cmake.in 
>                ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeCXXCompiler.cmake IMMEDIATE)
>+MARK_AS_ADVANCED(CMAKE_AR)
> 
> SET(CMAKE_CXX_COMPILER_ENV_VAR "CXX")

At one point all c++ projects used to enable the C language as well,
we do not have a test that does PROJECT(foo CXX) so it does not work.
As long as a test gets added with just CXX and it works I have no
problem with the change.

Thanks.

-Bill



More information about the CMake mailing list