Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what's the equivalence of Clang++'s "-rdynamic" option in CMake?

I'm trying to create a new programming language by reading LLVM documents. One of the documents is about "Kaleidoscope", a toy programming language. (tutorial's here: https://releases.llvm.org/9.0.0/docs/tutorial/LangImpl01.html).

All the codes in tutorial are written in a single file, and can be compiled by the command below:

clang++ -g -O3 toy.cpp -I/usr/lib/llvm-10/include -std=c++14  \
-fno-exceptions -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS \
-L/usr/lib/llvm-10/lib \
-rdynamic \
-lLLVM-10 -o toy

However, I want to manage my project by CMake. I've translate most of the command above into a CMakeLists.txt file (attached afterwards), besides the option "-rdynamic". Does anyone know how to add this option to my CMakeLists.txt ? Thanks in advance!

SET(CMAKE_CXX_COMPILER "/usr/bin/clang++")
INCLUDE_DIRECTORIES("/usr/lib/llvm-10/include")
LINK_DIRECTORIES("/usr/lib/llvm-10/lib")

SET(_GNU_SOURCE 1)
SET(__STDC_CONSTANT_MACROS 1)
SET(__STDC_FORMAT_MACROS 1)
SET(__STDC_LIMIT_MACROS 1)

# Project configuration
# omit something unrelated

FIND_PACKAGE(LLVM REQUIRED CONFIG)
TARGET_LINK_LIBRARIES(compiler LLVM-10)
like image 410
VKX Avatar asked Nov 02 '25 06:11

VKX


1 Answers

The clean way is to set the ENABLE_EXPORTS property:

set_property(TARGET compiler PROPERTY ENABLE_EXPORTS ON)
like image 150
iliis Avatar answered Nov 03 '25 22:11

iliis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!