Jump to content

CMake: Install both Debug and Release builds of SystemC

Recommended Posts


Is it possible to install two builds of SystemC (-DCMAKE_BUILD_TYPE=Release and -DCMAKE_BUILD_TYPE=Debug) simultaneously into a filesystem? 

So that find_package(SystemCLanguage) will link one of two, depending on CMAKE_BUILD_TYPE of application? 

(I know that there is a RelWithDebInfo option that tries to serve both release and debug purposes, but it does not work really well for debug because of enabled optimizations)

Link to post
Share on other sites

Hi @Roman Popov,

It is quite possible to have multiple installations of SystemC library.

This is what I have in my development environment setup:

# SystemC debug installation directory.

# SystemC release installation directory.

I currently use a shell script to switch between the environments but it is quite easy to add the condition in CMakeLists.txt/FindSystemCLanguage.cmake script to support such behaviour.


Ameya Vikram Singh

Link to post
Share on other sites
On 6/12/2017 at 11:23 PM, AmeyaVS said:

I currently use a shell script to switch between the environments but it is quite easy to add the condition in CMakeLists.txt/FindSystemCLanguage.cmake script to support such behaviour.


It turned out you need not to modify anything in CMake scripts.  There is a "secret" option -DCMAKE_DEBUG_POSTFIX .

Here is the procedure:


1) Build and install SystemC in Debug mode:

mkdir build_debug && cd build_debug
sudo make install

2) Build and install SystemC in Release mode:

mkdir build_rel && cd build_rel
sudo make install

3) Now you have both debug and release library installed in /opt/systemc :

ls -l /opt/systemc/lib/
total 14608
drwxr-xr-x 4 root root     4096 Jun 14 09:08 cmake
lrwxrwxrwx 1 root root       18 Jun 14 09:08 libsystemcd.so -> libsystemcd.so.2.3
lrwxrwxrwx 1 root root       37 Jun 14 09:08 libsystemcd.so.2.3 -> libsystemcd.so.2.3.2_pub_rev_20170606
-rw-r--r-- 1 root root 12751464 Jun 14 09:08 libsystemcd.so.2.3.2_pub_rev_20170606
lrwxrwxrwx 1 root root       17 Jun 14 09:12 libsystemc.so -> libsystemc.so.2.3
lrwxrwxrwx 1 root root       36 Jun 14 09:12 libsystemc.so.2.3 -> libsystemc.so.2.3.2_pub_rev_20170606
-rw-r--r-- 1 root root  2196784 Jun 14 09:12 libsystemc.so.2.3.2_pub_rev_20170606

4) Application project will pick required library automatically depending on CMAKE_BUILD_TYPE. Here is example CMakeLists.txt :

find_package(SystemCLanguage CONFIG REQUIRED)


set(SOURCE_FILES main.cpp)
add_executable(sysc_example ${SOURCE_FILES})
target_link_libraries(sysc_example SystemC::systemc)


Link to post
Share on other sites

Both proposed solutions work. The one proposed by the original poster itself is more elegant, as all build variants of the library end up in the same folder hierarchy so that the provided configuration files can pick up all variants. It is currently not automatically done by the SystemC's CMake build system as other build systems usually link blindly to libsystemc.so. The consequence is, that we currently need to install different build variants to separate directory trees. IMHO, it is worth discussing whether the installation of different build variants to a common tree is not the better approach in the long run to facilitate the life of the users who build their applications using CMake. For this, we should settle for good postfixes for all variants. The recommended build variant could either skip the postfix or provide additionally a link libsystemc.so to point to the recommended variant. Feedback is welcome!

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...