Search code examples
c++windowscmakewinapifltk

Setting up FLTK on windows with CMake


I'm trying to setup FLTK to build on windows with CMake with the Windows SDK.
So far here's what I've accomplished so far:

> svn co http://svn.easysw.com/public/fltk/fltk/branches/branch-1.3/ fltk-1.3
> cmake CMakeLists.txt -DOPTION_BUILD_EXAMPLES=NO -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=C:\dev\fltk-1.3
> nmake
> nmake install

No errors so far.

Then I created a test.cpp file with a hello world example I got off the documentation.
Here's my CMakeLists.txt:

cmake_minimum_required(VERSION 2.6)
project(Test)

find_package(FLTK REQUIRED NO_MODULE)
include(${FLTK_USE_FILE})

add_executable(test WIN32 test.cpp)

target_link_libraries(test fltk)

When I run cmake CMakeLists.txt I get an error asking me to set FLTK_DIR, so here's what I've got so far:

> cmake CMakeLists.txt
(error about FLTK_DIR)
> cmake CMakeLists.txt -DFLTK_DIR=C:\dev\fltk-1.3\CMake
> nmake

The last nmake command gives me this output:

[100%] Building CXX object CMakeFiles/test.dir/Test.cpp.obj
Test.cpp
Linking CXX executable test.exe
LINK : fatal error LNK1104: cannot open file ';.obj'
LINK Pass 1 failed. with 2
NMAKE : fatal error U1077: 'C:\dev\cmake-2.8.7-win32-x86\bin\cmake.exe' : return code '0xffffffff'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\Bin\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\Bin\nmake.exe"' : return code '0x2'
Stop.

I tried letting FLTK install itself to the default location, which didn't make any difference.

So, can anyone help me get this working?


Solution

  • After hours of working on this I finally figured it out.

    I had to comment out these 3 lines in FLTKConfig.cmake

    if(NOT " /STACK:10000000 /machine:X86 " STREQUAL "")
       set(FLTK_EXE_LINKER_FLAGS " /STACK:10000000 /machine:X86 ")
    endif(NOT " /STACK:10000000 /machine:X86 " STREQUAL "")
    

    They were causing it to add an ';' character into the command line for link.exe,
    causing it to try to link with ;.obj.

    I also had to rebuild FLTK, and change all occurences of "/MD" to "/MT" in CMakeCache.txt.