[cmake-developers] [CMake 0015829]: GenerateExportHeaders does not work for C

Mantis Bug Tracker mantis at public.kitware.com
Tue Nov 3 06:12:44 EST 2015


The following issue has been SUBMITTED. 
====================================================================== 
https://cmake.org/Bug/view.php?id=15829 
====================================================================== 
Reported By:                Julien Bigot
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   15829
Category:                   Modules
Reproducibility:            always
Severity:                   major
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2015-11-03 12:12 CET
Last Modified:              2015-11-03 12:12 CET
====================================================================== 
Summary:                    GenerateExportHeaders does not work for C
Description: 
This is a duplicate of issue 0012959 that has been closed as fixed but is not.

The module GenerateExportHeader creates some defines that work for C but it
require C++ to be enabled in order to be used. Indeed, the macro
check_cxx_compiler_flag is used in many places. That means you can't use
project(name C).

A fix for this is proposed in comment 0035809 of issue 0014456

Steps to Reproduce: 
This example will not works:

project(mylib C)
include(GenerateExportHeader)

add_compiler_export_flags()
add_library(mylib mylib.c)
generate_export_header(mylib)


[...]
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY
CMake Error at /usr/share/cmake-3.3/Modules/CheckCXXSourceCompiles.cmake:76
(try_compile):
  Unknown extension ".cxx" for file

    /[...]/CMakeFiles/CMakeTmp/src.cxx

  try_compile() works only for enabled languages.  Currently these are:

    C

  See project() command to enable other languages.
Call Stack (most recent call first):
  /usr/share/cmake-3.3/Modules/CheckCXXCompilerFlag.cmake:50
(CHECK_CXX_SOURCE_COMPILES)
  /usr/share/cmake-3.3/Modules/GenerateExportHeader.cmake:223
(check_cxx_compiler_flag)
  /usr/share/cmake-3.3/Modules/GenerateExportHeader.cmake:371
(_test_compiler_hidden_visibility)
  CMakeLists.txt:6 (generate_export_header)
[...]
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2015-11-03 12:12 Julien Bigot   New Issue                                    
======================================================================



More information about the cmake-developers mailing list