[CMake] win32 wrongly set on linux when using subdirectories

Stephen Sinclair radarsat1 at gmail.com
Wed Oct 1 17:43:25 EDT 2008


On Wed, Oct 1, 2008 at 5:33 PM, Bill Hoffman <bill.hoffman at kitware.com> wrote:
> Stephen Sinclair wrote:
>>
>> Hi,
>>
>> This is strange.
>> I'm using CMake on Fedora Core 9.  I have a few .c files that should
>> only be included when my project is compiled on Windows, but for some
>> reason it was including them on Linux.  I paired this down to a
>> minimal example that goes wrong.  It seems that my subdirectory has
>> the WIN32 variable set for some reason, while the top level directory
>> does not.  If I cd to the subdirectory, it works fine.  Same thing
>> happens using SUBDIRS instead of ADD_SUBDIRECTORY.
>>
>> $ cmake --version
>> cmake version 2.6-patch 1
>>
>> $ cat CMakeLists.txt
>> cmake_minimum_required(VERSION 2.6)
>> PROJECT(MyProj C)
>> ADD_SUBDIRECTORY(src)
>>
>> $ cat src/CMakeLists.txt
>> cmake_minimum_required(VERSION 2.6)
>>
>> if(WIN32)
>>   message(FATAL_ERROR windows detected wrongly)
>> endif(WIN32)
>>
>> $ cmake .
>> CMake Error at src/CMakeLists.txt:4 (message):
>>  windowsdetectedwrongly
>>
>>
>> -- Configuring done
>>
>> $ cd src/
>> $ cmake .
>> -- Configuring done
>> -- Generating done
>> -- Build files have been written to: /home/ssteve/project/src
>>
>
> I am unable to reproduce this.
>
> hoffman at hythloth:~/testit/b$ ~/cmake-2.6.1-Linux-i386/bin/cmake ..
> -- The C compiler identification is GNU
> -- Check for working C compiler: /usr/bin/gcc
> -- Check for working C compiler: /usr/bin/gcc -- works
> -- Detecting C compiler ABI info
> -- Detecting C compiler ABI info - done
> hello from subdir
> -- Configuring done
> -- Generating done
> -- Build files have been written to: /home/hoffman/testit/b
>
>
> Where did you get the cmake binary?  Try the one from
> http://www.cmake.org/cmake/resources/software.html
>
> You don't need to be root to install, just untar anywhere and use a full
> path to cmake.


Hm, well I got the binary from Fedora.  Since posting that I've
completely cleared all temp files from the project (git clean -fd) and
now it works as expected.  Sorry for the noise.  I should have tried
that before posting.  It must have been something left over from a
previous build attempt, but since I've cleared it I can't investigate
further.


Steve


More information about the CMake mailing list