[cmake-developers] [CMake 0012929]: The "-shared" gcc option is not provided for MODULE shared library if PROJECT command declares in ways
Mantis Bug Tracker
mantis at public.kitware.com
Thu Feb 2 18:52:52 EST 2012
The following issue has been SUBMITTED.
======================================================================
http://www.cmake.org/Bug/view.php?id=12929
======================================================================
Reported By: Zheng GONG
Assigned To:
======================================================================
Project: CMake
Issue ID: 12929
Category: CMake
Reproducibility: always
Severity: minor
Priority: low
Status: new
======================================================================
Date Submitted: 2012-02-02 18:52 EST
Last Modified: 2012-02-02 18:52 EST
======================================================================
Summary: The "-shared" gcc option is not provided for MODULE
shared library if PROJECT command declares in ways
Description:
The "-shared" gcc option is not provided for MODULE shared library, if PROJECT
command declares in some ways.
test cases:
PROJECT (${proj_name}) - OK
PROJECT (${proj_name}C CXX) - OK
without PROJECT command - OK
PROJECT (${proj_name}CXX) - FAIL
PROJECT (${proj_name}CXX C) - FAIL
CMAKE_SHARED_MODULE_CREATE_C_FLAGS gets its initial value in
CMakeCInformation.cmake from CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS.
It seems that if CMakeCXXInformation.cmake is called before
CMakeCInformation.cmake, The variable CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS will
take the default value of CMAKE_SHARED_MODULE_CREATE_C_FLAGS which is blank at
that moment.
As shown in CMakeCXXInformation.cmake files:
161 # repeat for modules
162 IF(NOT CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS)
163 SET(CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS
${CMAKE_SHARED_MODULE_CREATE_C_FLAGS})
164 ENDIF(NOT CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS)
The "-shared" gcc option is provided for SHARED library in any case.
Since CMakeGenericSystem.cmake gives CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS default
value "-shared". And in CMakeCXXInformation.cmake, '-shared' is passed to
CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS.
Steps to Reproduce:
CMakeLists.txt file:
PROJECT (test CXX)
ADD_LIBRARY(a MODULE a.cpp)
a.cpp file:
int a(void){ return 0;
}
compile with MinGW, related log:
Linking CXX shared module liba.dll
C:\cmake-2.8.7-win32-x86\bin\cmake.exe -E cmake_link_script
CMakeFiles\a.dir\link.txt --verbose=1
C:\cmake-2.8.7-win32-x86\bin\cmake.exe -E remove -f CMakeFiles\a.dir/objects.a
C:\MinGW\bin\ar.exe cr CMakeFiles\a.dir/objects.a @CMakeFiles\a.dir\objects1.rsp
C:\MinGW\bin\g++.exe -o liba.dll
-Wl,--major-image-version,0,--minor-image-version,0 -Wl,--whole-archive
CMakeFiles\a.dir/objects.a -Wl,--no-whole-archive -lkernel32 -luser32 -lgdi32
-lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32
c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../libmingw32.a(main.o): In function
`main':
C:\MinGW\msys\1.0\src\mingwrt/../mingw/main.c:73: undefined reference to
`WinMain at 16'
in which, CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS is empty rather than '-shared'
which cause the failure.
======================================================================
Issue History
Date Modified Username Field Change
======================================================================
2012-02-02 18:52 Zheng GONG New Issue
======================================================================
More information about the cmake-developers
mailing list