tpoechtrager / wclang

Cross compile source code easily for Windows with clang on Linux/Unix
GNU General Public License v2.0
302 stars 34 forks source link

do not install all triplets #9

Closed xantares closed 9 years ago

xantares commented 9 years ago

Hi,

I noticed ALL the triplets were installed, this fixes it, it only installs the symlinks triplet-clang[++] for which a triplet-gcc were found.

I did not know to write this cleanly with autotools, and I'm much conmfortable with cmake, as it remove the need for shell/m4/autoconf scripts scattered around, all the infrastructure is written in neat cmakelists.

Usage example and output:

[build] $ cmake -DCMAKE_INSTALL_PREFIX=$PWD/install ..
-- The C compiler identification is GNU 4.9.2
-- The CXX compiler identification is GNU 4.9.2
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Looking for getpid
-- Looking for getpid - found
-- Looking for unsetenv
-- Looking for unsetenv - found
-- Looking for include file sys/types.h
-- Looking for include file sys/types.h - found
-- Try C++11 flag = [-std=c++0x]
-- Performing Test CXX11_FLAG_DETECTED
-- Performing Test CXX11_FLAG_DETECTED - Success
-- Found CXX11: -std=c++0x  
-- Performing Test HAVE_STD_CHRONO
-- Performing Test HAVE_STD_CHRONO - Success
-- Found clang: /usr/bin/clang
-- Found mingw-gcc: /usr/bin/i686-w64-mingw32-gcc
-- Found mingw-gcc: /usr/bin/x86_64-w64-mingw32-gcc
-- Configuring done
-- Generating done
-- Build files have been written to: /home/xantares/projects/wclang/build

[xantares@arch64 build]$ make install
Scanning dependencies of target wclang
[ 33%] Building CXX object src/CMakeFiles/wclang.dir/wclang.cpp.o
[ 66%] Building CXX object src/CMakeFiles/wclang.dir/wclang_time.cpp.o
[100%] Building CXX object src/CMakeFiles/wclang.dir/wclang_cache.cpp.o
Linking CXX executable wclang
[100%] Built target wclang
Install the project...
-- Install configuration: ""
-- Installing: /home/xantares/projects/wclang/build/install/bin/wclang
-- Installing: /home/xantares/projects/wclang/build/install/bin/i686-w64-mingw32-clang
-- Installing: /home/xantares/projects/wclang/build/install/bin/i686-w64-mingw32-clang++
-- Installing: /home/xantares/projects/wclang/build/install/bin/x86_64-w64-mingw32-clang
-- Installing: /home/xantares/projects/wclang/build/install/bin/x86_64-w64-mingw32-clang++

[build]$ make package_source
Run CPack packaging tool for source...
CPack: Create package using TGZ
CPack: Install projects
CPack: - Install directory: /home/xantares/projects/wclang
CPack: Create package
CPack: - package: /home/xantares/projects/wclang/build/wclang-0.5.tar.gz generated.
CPack: Create package using TBZ2
CPack: Install projects
CPack: - Install directory: /home/xantares/projects/wclang
CPack: Create package
CPack: - package: /home/xantares/projects/wclang/build/wclang-0.5.tar.bz2 generated.

For discussion.

tpoechtrager commented 9 years ago

Installing all triples is actually a feature, but I do not mind if that is disabled by default.

I have found issues that should be fixed before a merge:

xantares commented 9 years ago

ok

tpoechtrager commented 9 years ago

Forgot one more thing: -std=gnu++0x should be used instead of -std=c++0x, -std=c++0x doesn't work with Cygwin (-std=c++0x seems to disable some non ANSI functions).

xantares commented 9 years ago

ok

tpoechtrager commented 9 years ago

Please do me one more favor, please squash your commits into a single one.

I would like to avoid having

etc. in the commit history.

xantares commented 9 years ago

could you cherry-pick 3add3c006421e73ec8d2099c6f336104331aec7d ?

tpoechtrager commented 9 years ago

Yes, works. Thanks for fixing all the issues.

I will push it once I have re-checked Cygwin and Debian/Wheezy. Probably done by tomorrow.

tpoechtrager commented 9 years ago

Two more things:

tpoechtrager commented 9 years ago

Another thing: make package_source ends up with a lot of unneeded files in the resulting packages, maybe you could invoke package.sh via make package_source for simplicity?

xantares commented 9 years ago

ok, fixed. for the package to be clean after make package_source, please compile out of source in a build* subdir which cmake ignores:

set (CPACK_SOURCE_IGNORE_FILES "/.git;/build;.*~;${CPACK_SOURCE_IGNORE_FILES}")

tpoechtrager commented 9 years ago

Thanks again.

Sorry for being so picky, but it seems the link detection isn't working correctly:

-- Found clang: /opt/other/llvm-3.5/bin/clang
-- Found mingw-gcc: /opt/other/llvm-3.5/bin/i686-w64-mingw32-gcc
CMake Error at CMakeLists.txt:102 (message):
  mingw-gcc found (/opt/other/llvm-3.5/bin/i686-w64-mingw32-gcc) but is not
  in the same directory as the clang binary (/opt/other/llvm-3.5/bin/clang).
  Please run 'ln -sf /usr/bin/i686-w64-mingw32-gcc-win32
  /opt/other/llvm-3.5/bin' to fix this issue.

-- Found mingw-gcc: /opt/other/llvm-3.5/bin/x86_64-w64-mingw32-gcc
CMake Error at CMakeLists.txt:102 (message):
  mingw-gcc found (/opt/other/llvm-3.5/bin/x86_64-w64-mingw32-gcc) but is not
  in the same directory as the clang binary (/opt/other/llvm-3.5/bin/clang).
  Please run 'ln -sf /usr/bin/x86_64-w64-mingw32-gcc-win32
  /opt/other/llvm-3.5/bin' to fix this issue.

'/opt/other/llvm-3.5/bin/x86_64-w64-mingw32-gcc' is indeed a correct symbolic link:

$ file /opt/other/llvm-3.5/bin/x86_64-w64-mingw32-gcc
/opt/other/llvm-3.5/bin/x86_64-w64-mingw32-gcc: symbolic link to `/usr/bin/x86_64-w64-mingw32-gcc'

The ln command should be corrected too and should include a wildcard rather than just symlinking gcc, like:

ln -sf /usr/bin/x86_64-w64-mingw32-* /opt/other/llvm-3.5/bin

It would also be great if the whole ln command could be shown in a single line (cmake seems to wrap its output to 80 cols, maybe this can be switched off somehow?)

xantares commented 9 years ago

ok. I can't seem to keep the message on one line.

tpoechtrager commented 9 years ago

Merged (with a few fixes on top).