View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0012929CMakeCMakepublic2012-02-02 18:522012-09-03 16:02
ReporterZheng GONG 
Assigned ToBrad King 
PrioritylowSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformMinGWOSMS Windows 7OS Version6.1.7600
Product VersionCMake 2.8.7 
Target VersionCMake 2.8.8Fixed in VersionCMake 2.8.8 
Summary0012929: The "-shared" gcc option is not provided for MODULE shared library CXX is enabled before C
DescriptionThe "-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 ReproduceCMakeLists.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@16'

in which, CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS is empty rather than '-shared' which cause the failure.
TagsNo tags attached.
Attached Filespatch file icon 0001-WIP-Fix-CXX-Fortran-MODULE-flags-when-enabled-before.patch [^] (3,217 bytes) 2012-02-03 10:45 [Show Content]

 Relationships

  Notes
(0028461)
Brad King (manager)
2012-02-03 10:46

Thanks for the detailed analysis.

Please test the attached patch against the Modules directory. Thanks.
(0028470)
Zheng GONG (reporter)
2012-02-03 15:24

I have tested the patch using MinGW+CDT, and it works. Thanks.
(0028471)
Brad King (manager)
2012-02-03 15:51

Thanks for testing! Integrated with a test:

  http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=74958450 [^]
(0030880)
David Cole (manager)
2012-09-03 16:02

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2012-02-02 18:52 Zheng GONG New Issue
2012-02-03 10:45 Brad King File Added: 0001-WIP-Fix-CXX-Fortran-MODULE-flags-when-enabled-before.patch
2012-02-03 10:45 Brad King Assigned To => Brad King
2012-02-03 10:45 Brad King Status new => assigned
2012-02-03 10:46 Brad King Note Added: 0028461
2012-02-03 10:46 Brad King Summary The "-shared" gcc option is not provided for MODULE shared library if PROJECT command declares in ways => The "-shared" gcc option is not provided for MODULE shared library CXX is enabled before C
2012-02-03 15:24 Zheng GONG Note Added: 0028470
2012-02-03 15:51 Brad King Note Added: 0028471
2012-02-03 15:51 Brad King Status assigned => resolved
2012-02-03 15:51 Brad King Resolution open => fixed
2012-04-19 15:48 David Cole Fixed in Version => CMake 2.8.8
2012-04-19 15:48 David Cole Target Version => CMake 2.8.8
2012-09-03 16:02 David Cole Note Added: 0030880
2012-09-03 16:02 David Cole Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team