Project

General

Profile

CMakeLists.txt for the Charts example??

Added by Mark Travis over 13 years ago

Does anyone have a good CMakeLists.txt file for creating any of the examples in a standalone manner?

I've been trying to understand CMake, but I can't get the charts example to compile using my own CMakeLists.txt file created according to the example on the main webtoolkit.eu website. I've attached the version I'm trying to get to work.

I've been trying to understand the CMake system that is used to build the examples, but I have to start with CMakeLists.txt in the main wt-3.1.10 directory, which embeds other CMakeLists.txt in the examples as well as the charts subdirectories.

There is a bunch of code that deals with Windows, which I don't need since I'm on OSX.

If anyone has a good Unix, Linux or OSX CMakeLists.txt that they use, please share!

Mark


Replies (3)

RE: CMakeLists.txt for the Charts example?? - Added by Wim Dumon over 13 years ago

There's an example in our FAQ, at http://redmine.emweb.be/projects/wt/wiki/Frequently_Asked_Questions#Q-How-do-I-build-my-newly-written-Hello-World-application which looks like this:

ADD_EXECUTABLE(myprog.wt
  MyProg1.C
  OtherFile.C
  AndEvenMoreCode.C
)

# For FastCGI deployment:
TARGET_LINK_LIBRARIES(myprog.wt
  wtfcgi wt someotherlib
)

# Or, for built-in httpd deployment:
# TARGET_LINK_LIBRARIES(myprog.wt
#   wthttp wt someotherlib
# )

INCLUDE_DIRECTORIES(/usr/local/wt/include)

You may also have to specify LINK_DIRECTORIES so that libwt.so, libwtfcgi.so, etc are found. Also, cmake's own homepages contain a ton of information on writing cmakefiles.

BR,

Wim.

RE: CMakeLists.txt for the Charts example?? - Added by Mark Travis over 13 years ago

I figured out what I needed. I wanted to reverse engineer the CMake files so as not to bother the list with things I should be able to figure out on my own.

Here's a summary in case someone else needs the same information I was looking for.

I DON'T use CMake for my projects. I like to use the managed make functions of my IDEs (Eclipse 3.7 or XCode 4.0 depending on my OS and mood). For me, this makes code and project navigation/debugging easier. Perhaps because I'm not educated on the additional methods and tools that one might use in a CMake environment.

Anyway, I was getting a bunch of object not found errors (x86_64) and I finally found the info toward the end of a CMake file in one of the examples that seem to apply to all of the examples. In this case, it was under /wt-3.1.11/build/examples/charts/CMakeFiles/charts.wt.dir/build.make. I found all of the libraries I needed to be linking to towards the bottom of the build.make file.

I added links to the following files in XCode: (Just drag them to the Project folder and add them to the executable but do NOT copy the files)

From /usr/local/lib:

libboost_date_time.dylib

libboost_filesystem.dylib

libboost_program_options.dylib

libboost_random.dylib

libboost_regex.dylib

libboost_signals.dylib

libboost_system.dylib

libboost_thread.dylib

From /usr/lib:

libz.dylib

libssl.dylib

and from /wt-3.1.11/build/src:

libwt.dylib

libwthttp.dylib

(Note: For Eclipse, you add these libraries without the "lib" prefix and without the "dylib" post-fix. ie. "boost_date_time" instead of "libboost_date_time.dylib". These are added in Project~~Properties>C/C BuildSettings~~>Cross G Linker->Libraries.

For the header paths, I added

/wt-3.1.11/src

/wt-3.1.11/build # This is where WConfig.h lives after the wt package has been installed

Same exercise for the library paths.

Hope this helps others.

Mark

RE: CMakeLists.txt for the Charts example?? - Added by Wim Dumon over 13 years ago

That looks correct. One remark: instead of refering to the headers and libraries in the build and src directories, it is cleaner to do a 'make install' and refer to the include and lib directories of your installation target directory. Set that directory by specifying the CMAKE_INSTALL_PREFIX variable (or change it in your CMakeCache.txt file).

Wim.

Note: CMake can generate both XCode and Eclipse projects, so once you have a good cmake file you can easily switch between both IDEs - but you're of course free to use anything you want, as you just demonstrated ;-)

    (1-3/3)