cmake mixed compile C/C ++ and Object-CJoven


When CMAKE mixed compile C / C ++ and Object-C, set the compilation option to pass
Add_compile_optings or
Correctly modify through the set command

Use these two methods to effect the same effect under some cases (note that in some cases, not under all cases), their differences are as follows:

The compile option added by the

   add_compile_optionscommand is for all compilers (including C and C ++ compilers).

    set command settingsCMAKE_C_FLAGSorCMAKE_CXX_FLAGSvariables are only for C and C ++ compilers.

Therefore, in the compilation of the hybrid program of C/C ++ and OC, when setting “-X Objective-C ++”, it can only be usedadd_compile_optings to add compilation options, otherwise, C/C ++ will report inexplicable mistakes when compiling the OC code.

So, when C/C ++ and OC are mixed with compile, the cmakelists.txt should be written as follows:

    add_compile_options(-x objective-c++)
    set(CMAKE_EXE_LINKER_FLAGS “-framework Cocoa -framework AppKit -framework CoreData -framework Foundation”)

The corresponding G ++ command line parameters are as follows:

More than

    g++ -x objective-c++ -framework Cocoa -framework AppKit -framework CoreData -framework Foundation

, compile, can successfully produce executable files.


Random Posts

cmake basic command & cross compilation configuration & module writing

HTML5 adds block -level elements to jQuery plug -in tutorial with different shapes of SVG graphics

Computer visual thesis-20121-06-21

ARCGIS Second Development Basic Tutorial (06): Basic operations about the layer

java learning route map