c++cmakeqmakecuddcatkin

How to port a qmake project to cmake


I would like to "port" this C++ project, which uses qmake (i.e., a Tool.pro file) for building, to cmake.

Essentially, I'm asking how to go about writing the necessary CMakeLists.txt file(s) by looking at the Tool.pro file above.

This is what I've done so far:

include_directories(../lib/cudd-2.5.0/include BFAbstractionLibrary)

add_executable(slugs BFAbstractionLibrary/bddDump.cpp BFAbstractionLibrary/BFCuddVarVector.cpp BFAbstractionLibrary/BFCudd.cpp BFAbstractionLibrary/BFCuddManager.cpp \
    BFAbstractionLibrary/BFCuddVarCube.cpp tools.cpp synthesisAlgorithm.cpp synthesisContextBasics.cpp variableManager.cpp \
    BFAbstractionLibrary/BFCuddMintermEnumerator.cpp)

add_library(lcudd ../lib/cudd-2.5.0/cudd)
add_library(ldddmp ../lib/cudd-2.5.0/dddmp)
add_library(lmtr ../lib/cudd-2.5.0/mtr)
add_library(lepd ../lib/cudd-2.5.0/epd)
add_library(lst ../lib/cudd-2.5.0/st)
add_library(lutil ../lib/cudd-2.5.0/util)

target_link_libraries(slugs lcudd, lutil, lmtr, lst, ldddmp, lepd)

This is definitely missing the headers that are present in the Tool.pro file. I'm also not sure what I have to do with the flags in the first 24 lines of the Tool.pro file.

Could you point me in the right direction please?


Solution

  • After sacrificing some of the modularity and complexity of the Tool.pro file above, I was able to build the project using cmake. Here's the CMakeLists.txt file that I wrote:

    project( slugs )
    
    cmake_minimum_required( VERSION 2.6 )
    
    add_definitions ( -Wall )
    add_definitions ( -D USE_CUDD )
    
    set ( BDDFLAGS "-mtune=native -malign-double -DHAVE_IEEE_754 -DBSD -DCUDD_COMPILER_OPTIONS_SET" ) # hardcoded for x86_64
    add_definitions ( ${BDDFLAGS} )
    
    set ( CMAKE_BUILD_TYPE Debug )
    set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -std=gnu++0x -Wall -Wextra ${BDDFLAGS}")
    
    include_directories ( ../lib/cudd-2.5.0/include BFAbstractionLibrary )
    
    set ( slugs_HDRS
        BFAbstractionLibrary/BF.h
        BFAbstractionLibrary/BFCudd.h
        gr1context.hpp
        variableTypes.hpp
        variableManager.hpp
        extensionExtractExplicitStrategy.hpp
        extensionRoboticsSemantics.hpp
        extensionWeakenSafetyAssumptions.hpp
        extensionBiasForAction.hpp
        extensionComputeCNFFormOfTheSpecification.hpp
        extensionCounterstrategy.hpp
        extensionExtractExplicitCounterstrategy.hpp
        extensionIncrementalSynthesis.hpp
        extensionFixedPointRecycling.hpp
        extensionInteractiveStrategy.hpp
        extensionIROSfastslow.hpp
        extensionAnalyzeInitialPositions.hpp
        extensionAnalyzeAssumptions.hpp
        BFAbstractionLibrary/BFCuddMintermEnumerator.h
        extensionComputeInterestingRunOfTheSystem.hpp
        extensionAnalyzeSafetyLivenessInteraction.hpp
        extensionAbstractWinningTraceGenerator.hpp
        extensionInterleave.hpp
        extensionPermissiveExplicitStrategy.hpp
        extensionIncompleteInformationEstimatorSynthesis.hpp
        extensionNondeterministicMotion.hpp
        extensionExtractSymbolicStrategy.hpp
        extensionTwoDimensionalCost.hpp
        )
    
    set ( slugs_SRCS
        main.cpp
        BFAbstractionLibrary/bddDump.cpp
        BFAbstractionLibrary/BFCuddVarVector.cpp
        BFAbstractionLibrary/BFCudd.cpp
        BFAbstractionLibrary/BFCuddManager.cpp
        BFAbstractionLibrary/BFCuddVarCube.cpp
        tools.cpp
        synthesisAlgorithm.cpp
        synthesisContextBasics.cpp
        variableManager.cpp
        BFAbstractionLibrary/BFCuddMintermEnumerator.cpp
        )
    
    set ( slugs_LIBS
        -L../lib/cudd-2.5.0/cudd
        -L../lib/cudd-2.5.0/util
        -L../lib/cudd-2.5.0/mtr
        -L../lib/cudd-2.5.0/st
        -L../lib/cudd-2.5.0/dddmp
        -L../lib/cudd-2.5.0/epd
        -lcudd
        -ldddmp
        -lmtr
        -lepd
        -lst
        -lutil
        )
    
    add_executable ( slugs ${slugs_SRCS} )
    
    target_link_libraries (slugs ${slugs_LIBS})