[cmake-developers] [CMake 0016048]: Segfault on target_link_libraries() with aliased target from another subdirectory

Mantis Bug Tracker mantis at public.kitware.com
Fri Apr 1 15:22:37 EDT 2016


The following issue has been SUBMITTED. 
====================================================================== 
https://public.kitware.com/Bug/view.php?id=16048 
====================================================================== 
Reported By:                arlbranch
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   16048
Category:                   CMake
Reproducibility:            always
Severity:                   crash
Priority:                   high
Status:                     new
====================================================================== 
Date Submitted:             2016-04-01 15:22 EDT
Last Modified:              2016-04-01 15:22 EDT
====================================================================== 
Summary:                    Segfault on target_link_libraries() with aliased
target from another subdirectory
Description: 
CMake crashes with a segfault when target_link_libraries is used to add a
dependency on an alias of a target that was added in a different subdirectory.

Complete Example
================
[branch at fortuna on /dev/pts/1] 1150 ~/repositories/test/cmake_segfault
$ cmake --version
cmake version 3.5.1

CMake suite maintained and supported by Kitware (kitware.com/cmake).
[branch at fortuna on /dev/pts/1] 1151 ~/repositories/test/cmake_segfault
$ ls -lR
.:
total 12
drwxr-xr-x 2 branch atlsdd 4096 Apr  1 13:37 alib/
drwxr-xr-x 2 branch atlsdd 4096 Apr  1 14:14 blib/
-rw-r--r-- 1 branch atlsdd   98 Apr  1 13:18 CMakeLists.txt

./alib:
total 4
-rw-r--r-- 1 branch atlsdd 87 Apr  1 13:24 CMakeLists.txt

./blib:
total 4
-rw-r--r-- 1 branch atlsdd 162 Apr  1 13:38 CMakeLists.txt
[branch at fortuna on /dev/pts/1] 1152 ~/repositories/test/cmake_segfault
$ cat CMakeLists.txt
cmake_minimum_required(VERSION 2.8.11)
project(top)
add_subdirectory(alib)
add_subdirectory(blib)
[branch at fortuna on /dev/pts/1] 1153 ~/repositories/test/cmake_segfault
$ cat alib/CMakeLists.txt
add_library(alib alib.c)
set_source_files_properties(alib.c PROPERTIES GENERATED TRUE)
[branch at fortuna on /dev/pts/1] 1154 ~/repositories/test/cmake_segfault
$ cat blib/CMakeLists.txt
add_library(blib blib.c)
set_source_files_properties(blib.c PROPERTIES GENERATED TRUE)

add_library(alib::alib ALIAS alib)
target_link_libraries(blib alib::alib)
[branch at fortuna on /dev/pts/1] 1155 ~/repositories/test/cmake_segfault
$ mkdir build && cd build
[branch at fortuna on /dev/pts/1] 1156 ~/repositories/test/cmake_segfault/build
$ cmake ..
-- The C compiler identification is GNU 5.3.0
-- The CXX compiler identification is GNU 5.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
Segmentation fault (core dumped)


Steps to Reproduce: 
1) create the project in the Description
2) run cmake against it

Additional Information: 
Also seen on MacOS.

This is a regression, cmake 3.4 does not crash.
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2016-04-01 15:22 arlbranch      New Issue                                    
======================================================================



More information about the cmake-developers mailing list