Using cmake to generate cinder projects on windows


#1

Hi all,

I’m moving my build system to CMake and I’m digging all the awesome support that has been added recently. I’m pretty new to CMake but am really enjoying it so far. My day to day work flow is on Windows 10 however and I understand CMake support on windows is “experimental”. That said, I’m getting the following error trying to generate my project:

CMake Error at dependencies/cinder/proj/cmake/modules/cinderMakeApp.cmake:65 (find_package):
  Could not find a package configuration file provided by "cinder" with any
  of the following names:

    cinderConfig.cmake
    cinder-config.cmake

  Add the installation prefix of "cinder" to CMAKE_PREFIX_PATH or set
  "cinder_DIR" to a directory containing one of the above files.  If "cinder"
  provides a separate development package or SDK, be sure it has been
  installed.

I haven’t dug around in cinder’s CMake files enough to know exactly why i’m getting this error…hoping someone can enlighten me.

Note: I did have it working at one point, but i erased my build folder to fix something and this error reappeared.

Here’s the appropriate CMakeLists.txt for my app:

cmake_minimum_required(VERSION 3.0)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../cmake) # main (top) cmake dir

set( CMAKE_VERBOSE_MAKEFILE ON )

project("MyCinderProject")

get_filename_component( CINDER_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../dependencies/cinder" ABSOLUTE )
get_filename_component( APP_PATH "${CMAKE_CURRENT_SOURCE_DIR}/src/app" ABSOLUTE )

include( "${CINDER_PATH}/proj/cmake/modules/cinderMakeApp.cmake" )

# CMake useful variables
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/${PROJECT_NAME}")

set(VERSION_MAJOR "0")
set(VERSION_MINOR "1")
set(VERSION_PATCH "0")
set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})

file(GLOB PROJ_INCLUDE
    "src/*.h"
    "src/*.hpp"
)

file(GLOB PROJ_SRC
    "src/*.cpp"
)

ci_make_app(
    APP_NAME    "MyCinderApp"
    CINDER_PATH ${CINDER_PATH}
    SOURCES     ${PROJ_INCLUDE} ${PROJ_SRC} ${APP_PATH}/Resources.h ${APP_PATH}/main.cpp
    INCLUDES    src/ 
)

add_subdirectory(doc)
add_subdirectory(test)

Thanks everyone!

~michael


#2

UPDATE:

Turns out it was running fine with the basic cmake .. command run from my build folder, but explicitly using the win64 generator produces the error:

$ cmake .. -G"Visual Studio 14 2015 Win64"
-- The C compiler identification is MSVC 19.0.23918.0
-- The CXX compiler identification is MSVC 19.0.23918.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- App is set to msw.
CMake Warning at dependencies/cinder/proj/cmake/configure.cmake:45 (message):
  CMake support on Windows is experimental and may be incomplete.
Call Stack (most recent call first):
  dependencies/cinder/proj/cmake/modules/cinderMakeApp.cmake:23 (include)
  projects/MyCinderProject/CMakeLists.txt:30 (ci_make_app)


CMake Error at dependencies/cinder/proj/cmake/modules/cinderMakeApp.cmake:65 (find_package):
  Could not find a package configuration file provided by "cinder" with any
  of the following names:

    cinderConfig.cmake
    cinder-config.cmake

  Add the installation prefix of "cinder" to CMAKE_PREFIX_PATH or set
  "cinder_DIR" to a directory containing one of the above files.  If "cinder"
  provides a separate development package or SDK, be sure it has been
  installed.
Call Stack (most recent call first):
  projects/MyCinderProject/CMakeLists.txt:30 (ci_make_app)


-- Configuring incomplete, errors occurred!
See also "C:/code/cpp_project/build/CMakeFiles/CMakeOutput.log".

where this works fine:

$ cmake ..
-- Building for: Visual Studio 14 2015
-- The C compiler identification is MSVC 19.0.23918.0
-- The CXX compiler identification is MSVC 19.0.23918.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- App is set to msw.
CMake Warning at dependencies/cinder/proj/cmake/configure.cmake:45 (message):
  CMake support on Windows is experimental and may be incomplete.
Call Stack (most recent call first):
  dependencies/cinder/proj/cmake/modules/cinderMakeApp.cmake:23 (include)
  projects/MyCinderProject/CMakeLists.txt:30 (ci_make_app)


-- Found Doxygen: C:/Program Files/doxygen/bin/doxygen.exe (found version "1.8.13")
-- Configuring done
-- Generating done
-- Build files have been written to: C:/code/cpp_project/build

Cmake has a hard time generating x64 projects on windows anyway, so maybe i will just always have to add the x64 build manually. Any tips?


#3

Hm, I didn’t realize that cmake x64 bit projects were a problem, I would hope we could solve this though, as 32-bit is quickly becoming irrelevant. Is there some way to specify the architecture as a command line option? I see there is some MSVC PlatformToolset manipulation here, although I’m unfamiliar with that part and haven’t tested generating VS projects myself.

Also just posted here with some background information on the state of cmake on windows.

cheers,
Rich


#4

Thanks Rich! I’m really looking forward to cmake support in vs2017 it should make cross platform development a LOT easier.

I just figured out this thread is actually about two different problems:

  1. there’s no good way to do 32 vs 64 bit builds with cmake on windows, so the best practice is to commit to an architecture or maintain two build folders if you have to support both architectures. The only annoying thing this that the default arch on windows is Win32 so to generate an x64 project (which is pretty much always the case) you have to flag -D"Visual Studio 14 2015 Win64" when you generate your project. Not such a big deal if your build system works well and you aren’t constantly changing the cmake files…unlike mine :stuck_out_tongue:

  2. This is a new one I JUST figured out. The generated projects have these flags set:

#platform_msw.cmake
# Static library flags
    set( CINDER_STATIC_LIBS_FLAGS_DEBUG     "/NODEFAULTLIB:LIBCMT /NODEFAULTLIB:LIBCPMT" )
    set( CINDER_STATIC_LIBS_FLAGS_RELEASE   "/NODEFAULTLIB:LIBCMT /NODEFAULTLIB:LIBCPMT" )

In debug this seems fine, but in release, it fails to link to the runtime library and all hell breaks loose. Removing the specific ignores on release fixes the problem for me. I also looked at the same sample i’m testing against (_opengl/Cube) and the provided VS proj doesn’t ignore them in release, so i think that perhaps this is just a typo?

I’m not super familiar with what that setting is all about so i’m not sure which is the case, but at any rate i’m going to submit an issue and PR about it.

I’ve tested most of the cmake project generation features for windows and its looking good except for these two things (and a symlink problem i PRed against as well). I’ll keep logging things as they come up!

~Michael


#5

New update: we’re slowly but surely solving the issues with cmake generated VS project files, remaining TODO list is at: https://github.com/cinder/Cinder/issues/1801

We’re going to aim for supporting this in 0.9.2 with VS 2015, as there are much less libaries we need to link to on windows (no boost, hurrah).

If you find other issues, please list em on that ticket.

cheers,
Rich