Build fails with CMake 3.6.2.1 and 3.13.0-rc3 on Cygwin + Windows
Created by: hsahasra
@trilinos/Trilinos
Lables: build cmake cygwin windows
Expectations
The Windows+Cygwin build should pass.
Current Behavior
The build fails with the following error on Cygwin (setup version 2.893) + CMake (3.6.2-1) + Windows (10):
/cygdrive/g/Trilinos/Trilinos-source/packages/teuchos/parameterlist/src/Teuchos_XMLPerfTestArchive.cpp: In function ‘Teuchos::PerfTestResult Teuchos::PerfTest_CheckOrAdd_Test(Teuchos::XMLTestNode, Teuchos::XMLTestNode, std::string, std::string)’: /cygdrive/g/Trilinos/Trilinos-source/packages/teuchos/parameterlist/src/Teuchos_XMLPerfTestArchive.cpp:258:5: error: ‘gethostname’ was not declared in this scope gethostname (hostname, 255); ^~~~~~~~~~~ /cygdrive/g/Trilinos/Trilinos-source/packages/teuchos/parameterlist/src/Teuchos_XMLPerfTestArchive.cpp:258:5: note: suggested alternative: ‘hostname’ gethostname (hostname, 255); ^~~~~~~~~~~ hostname make[2]: *** [packages/teuchos/parameterlist/src/CMakeFiles/teuchosparameterlist.dir/build.make:1119: packages/teuchos/parameterlist/src/CMakeFiles/teuchosparameterlist.dir/Teuchos_XMLPerfTestArchive.cpp.o] Error 1 make[1]: *** [CMakeFiles/Makefile2:1706: packages/teuchos/parameterlist/src/CMakeFiles/teuchosparameterlist.dir/all] Error 2 make[1]: *** Waiting for unfinished jobs....
Motivation and Context
CMake no longer defines WIN32 on version > 2.8.4: https://github.com/LuaDist/Repository/issues/46
Following warning is issued during configuration phase:
CMake Warning at /usr/share/cmake-3.13.0-rc3/Modules/Platform/CYGWIN.cmake:15 (message): CMake no longer defines WIN32 on Cygwin!
(1) If you are just trying to build this project, ignore this warning or quiet it by setting CMAKE_LEGACY_CYGWIN_WIN32=0 in your environment or in the CMake cache. If later configuration or build errors occur then this project may have been written under the assumption that Cygwin is WIN32. In that case, set CMAKE_LEGACY_CYGWIN_WIN32=1 instead.
(2) If you are developing this project, add the line
set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required
at the top of your top-level CMakeLists.txt file or set the minimum required version of CMake to 2.8.4 or higher. Then teach your project to build on Cygwin without WIN32. Call Stack (most recent call first): /usr/share/cmake-3.13.0-rc3/Modules/CMakeSystemSpecificInformation.cmake:26 (include) /cygdrive/g/Trilinos/Trilinos-source/cmake/tribits/core/config_tests/fmangle/CMakeLists.txt:41 (PROJECT)
Definition of Done
Build should succeed on CMake > 2.8.4 + Cygwin + Windows
Possible Solution
Add CMAKE_LEGACY_CYGWIN_WIN32=1 to the top CMakeLists.txt
Steps to Reproduce
Install latest Cygwin with gcc, gfortran, g++, CMake, make, openmpi-devel, openblas, lapack-devel, zlib-devel.
Configure Trilinos:
cmake -DTPL_ENABLE_MPI=ON -DMPI_BASE_DIR=/ -DTrilinos_ENABLE_Epetra=ON -DTpetra_INST_SERIAL:BOOL=ON -DTrilinos_ENABLE_AztecOO=ON -DTrilinos_ENABLE_Ifpack=ON -DTrilin os_ENABLE_OpenMP=ON -DCMAKE_INSTALL_PATH=/cygdrive/g/Trilinos/trilinos /cygdrive/g/Trilinos/Trilinos-source
Compile:
make
Your Environment
Windows: 10 Cygwin: 2,893 (64 bit) CMake: Default Cygwin-3.6.2-1 or manually compiled 3.13.0-rc3 gcc/g++/gfortran: 7.3.0-3 make: 4.2.1-2 zlib: 1.2.11-1 openmpi: 3.1.2-2 openblas: 0.3.3-1 lapack: 3.8.0-1