cmake and windows build (or better say x-platform)

Jan 12, 2015 at 5:45 AM
Edited Jan 12, 2015 at 5:50 AM
hi,
I created a library on Mac that uses Casablanca. And now fighting compiling this library on Windows but it seems Casablabca does not support CMake building on Windows, is this correct?

In CMakeLists.txt in section "# Compiler (not platform) specific settings" I see section for Android, IOS/Clang, Gnu and "Unknown compiler, success is doubtful" that Microsoft compiler will fall into.

What is supposed workflow for cross platform projects?

In Mac build I just added Casablanca into subfolder and put
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared Libraries.")
set(BUILD_TESTS OFF CACHE BOOL "Build tests.")
set(BUILD_SAMPLES OFF CACHE BOOL "Build samples.")
add_subdirectory(external/casablanca/Release)

# Get the Casablanca properties from the Casablanca subdirectory
get_directory_property(Casablanca_LIBRARY
    DIRECTORY external/casablanca/Release
    DEFINITION Casablanca_LIBRARY)

get_directory_property(Casablanca_INCLUDE_DIR
    DIRECTORY external/casablanca/Release
    DEFINITION Casablanca_INCLUDE_DIR)
message(STATUS "casablanca lib dir: ${Casablanca_LIBRARY}")
message(STATUS "casablanca inc dir: ${Casablanca_INCLUDE_DIR}")
this way everything compiles smoothly on Mac and when i run same cmake step on Windows I first get "Unknown compiler..." and error that "You have called ADD_LIBRARY for library libcpprest without any source filed..."

Any ideas what to look or how to redo my workflow?


Thank you!
Coordinator
Jan 12, 2015 at 6:16 PM
Hi denveloper,

The easiest solution is to use NuGet + MsBuild project files on Windows (and android-via-windows), and CMake for other platforms. This is what we use inside C++REST itself.

If you prefer source over binaries, the best path would be to use MsBuild project files and add the relevant C++REST project files to your solution with appropriate references between the projects.

If you're willing to dig into some more complex CMake stuff, you could convince it to generate one of the above two cases or add windows as a target to the C++REST CMakeLists.txt. If you want to do this last one, look through the .vcxproj files under Release\src\build\ to figure out what flags you need.

Sincerely,
roschuma
Marked as answer by roschuma on 1/13/2015 at 1:57 PM
Jan 13, 2015 at 3:34 AM
hi roschuma,
Thank you very much for the reply (and library!). Taking in account that under Windows it is possible to compile libcpprest once and put it as precompiled i will use this path for now.