Jump to content
Roman Popov

CMake: Install both Debug and Release builds of SystemC

Recommended Posts

Hello,

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)

Share this post


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.
$HOME/apps/systemc-2.3.1a_debug

# SystemC release installation directory.
$HOME/apps/systemc-2.3.1a_release

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.

Regards,

Ameya Vikram Singh

Share this post


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
cmake ../ -DCMAKE_CXX_STANDARD=11 -DCMAKE_BUILD_TYPE=Debug -DCMAKE_DEBUG_POSTFIX=d
make
sudo make install

2) Build and install SystemC in Release mode:

mkdir build_rel && cd build_rel
cmake ../ -DCMAKE_CXX_STANDARD=11 -DCMAKE_BUILD_TYPE=Release
make
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)
add_definitions(-DSC_INCLUDE_DYNAMIC_PROCESSES)

set (CMAKE_CXX_STANDARD ${SystemC_CXX_STANDARD} )

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

 

Share this post


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!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×