Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Migrate from Jam to CMake

I understand Jam builds existing projects and CMake generates projects to build. But, given I'd rather be generating projects I could use in various IDE's rather than trying to integrate Jam into those IDE's, has anybody had any experience/success turning a Jamfile into a CMakeLists.txt file?

like image 267
cppguy Avatar asked Apr 10 '12 21:04

cppguy


2 Answers

I used to use Jam for all my Linux projects since it was easier than regular makefiles. I then discovered CMake and have not gone back. It's about as easy to write CMakeLists.txt files as it is to write Jamfiles, and you get platform-specific IDE support for free, though IMO the IDE projects are not quite as clean as something generated by hand.

From what I have seen, very few people use Jam these days, despite its many strengths. It does claim to be able to build on various platforms, but at the same time, it does not seem to be enjoying active development any more, so I tend to distrust its multiplatform claims.

As far as I know, there is no tool for automatically converting a hierarchy of Jamfiles into a hierarchy of CMakeLists.txt files, though such a tool would certainly be a feasible project. However, thanks to the unpopularity of Jam and to a lesser extent, CMake, unless you or I find some free time, such a tool is not on the horizon. :(

If your project is not too complex, some simple search and replace operations should transform a Jamfile into a CMakeLists.txt file. If your project is complex, then converting them by hand is probably your best bet.

Some simple transformations:

  • HDRS += a.h b.h c.h ; becomes include_directories(a.h b.h c.h)
  • Main HelloWorld : main.cpp utils.cpp ; becomes add_executable(HelloWorld main.cpp utils.cpp utils.h)
  • Library helper : helper.cpp becomes add_library(helper STATIC helper.cpp helper.h)
  • SubDir foo ; becomes add_subdirectory(foo)
  • LinkLibraries HelloWorld : libhelper ; becomes target_link_libraries(HelloWorld helper)

The IDE projects that CMake generates do not automatically include related header files, hence I explicitly included important ones in the examples above. There is a nice example here, if you haven't seen it already.

like image 102
Randall Cook Avatar answered Oct 01 '22 20:10

Randall Cook


For Jam to CMake conversion, it might be useful to try extending vcproj2cmake to have a Jam parser implementation, too (the generator part for CMake syntax text streams is fairly capable now).

like image 39
vcproj2cmake Avatar answered Oct 01 '22 22:10

vcproj2cmake