district10 / cmake-templates Goto Github PK
View Code? Open in Web Editor NEWSome CMake Templates (examples). Qt, Boost, OpenCV, C++11, etc 一些栗子
Home Page: http://blog.tangzhixiong.com/post-0100-cmake-templates.html
License: MIT License
Some CMake Templates (examples). Qt, Boost, OpenCV, C++11, etc 一些栗子
Home Page: http://blog.tangzhixiong.com/post-0100-cmake-templates.html
License: MIT License
Qt4 doesn't provide an official vs2015 prebuild, and you can't easily compile one yourself.
But it is possible. See http://whudoc.qiniudn.com/2016/vs2015-qt4-playground.zip (14 MB).
14 MB = 13.6 MB of qt4 prebuild (release version only, a tiny qt4!) + 1 demo qt project.
The README.txt inside is written in chinese, steps are:
qt4-vs2015x64.7z
in current dir;set PATH=%CD%\qt4-vs2015x64\bin;%PATH%
"; (better add this path to %PATH%
, it's needed at runtime too.)cmake-gui demo
";VS2015 WIN64
; 3) configure, build;.sln
file in build dir, build the release version (not debug!).You should be able to build & run this qt4 project inside VS2015.
See more at qt4-vs2015x64/README.md at master · district10/qt4-vs2015x64.
Boost is great, for it's powerful. Boost is bad, for it's way to BIG!
You can't expect other people to configure this gaint library just for compiling your code. Here is a solution: bcp.
The bcp utility is a tool for extracting subsets of Boost, it's useful for Boost authors
who want to distribute their library separately from Boost, and for Boost users who
want to distribute a subset of Boost with their application.bcp can also report on which parts of Boost your code is dependent on, and what
licences are used by those dependencies.
Here is my fork of bcp to demonstrate how to extract code from Boost and make a static compilation againt your own MiniBoost: district10/bcp at standalone.
Another example is my fork of @satoren's kaguya: 4ker/kaguya at standalone. Kaguya is a lua C++ binding, depends on C++11 compatible compiler or Boost library. I made this standalone Kaguya pack, so this lua binding can work on Windows with VS2010 without configuring Boost. (Though I've already got one.)
This two examples are extremely friendly, you can git clone it, cmake, build without hurdle. (If you come to any problems, please tell me. 😄)
$ brew install cmake boost qt5 glew opencv
# 4 -> 5
$ brew unlink qt@4
$ brew link qt --force
# 5 -> 4
$ brew unlink qt
Unlinking /usr/local/Cellar/qt/5.9.1... 406 symlinks removed
$ brew link qt@4 --force
Linking /usr/local/Cellar/qt@4/4.8.7_2... 666 symlinks created
Caution: If you don't have Qt4 configured, use cpp
instead of qt4-project
. The work-through is the same.
Tip: Better to use VS2015. (I'll leave the tutorial here 'cause I don't have time to re-screenshot.)
CMakeLists.txt
to CMakeGUI*.sln
with Visual Studio# goto source dir
cd module
mkdir build && cd build
cmake -G"CodeBlocks - Unix Makefiles" ..
tip:
you can run cmake
to get all your possible generators:
Generators
The following generators are available on this platform:
Unix Makefiles = Generates standard UNIX makefiles.
Ninja = Generates build.ninja files (experimental).
CodeBlocks - Ninja = Generates CodeBlocks project files.
CodeBlocks - Unix Makefiles = Generates CodeBlocks project files.
Eclipse CDT4 - Ninja = Generates Eclipse CDT 4.0 project files.
Eclipse CDT4 - Unix Makefiles
= Generates Eclipse CDT 4.0 project files.
KDevelop3 = Generates KDevelop 3 project files.
KDevelop3 - Unix Makefiles = Generates KDevelop 3 project files.
Sublime Text 2 - Ninja = Generates Sublime Text 2 project files.
Sublime Text 2 - Unix Makefiles
= Generates Sublime Text 2 project files.
It seems sublime is a great choice. I'll cover that section later.
because the building process is based on Makefile, you can also run these qt examples,
like:
I make the build directory:
mkdir build && cd build
I do cmake ..
And I obtain the next ERROR:
CMake Error: The source directory "~/git/cmake-templates" does not appear to contain CMakeLists.txt.
The instructions are USELESS. Please REVIEW it BEFORE publish any USELESS solution!!!
When you find_package( OpenCV REQUIRED )
in CMakeLists.txt, it just look for OpenCVConfig.cmake
under OpenCV_DIR
, aka include( $ENV{OpenCV_DIR}/OpenCVConfig.cmake )
.
If you want to use OpenCV2 & OpenCV3 in your system at the same time. Here is my solution:
1.
First goto OpenCV official download page, download opencv-2.4.x.exe
and opencv-3.1.x.exe
.
2.
Second, extract them, set these two proper environment variables:
OpenCV2_DIR
-> D:\OpenCV\build
OpenCV3_DIR
-> D:\OpenCV3\build
OpenCV_DIR
-> %OpenCV_DIR%
or %OpenCV3_DIR%
(which you prefer)add to PATH
:
%OpenCV2_DIR%\x64\vc10\bin
(for VS2010 generated exe)%OpenCV3_DIR%\x64\vc14\bin
(for VS2015 generated exe)reboot may needed.
3.
Last, generated VS2010, VS2015 project to use OpenCV 2, OpenCV 3 with CMake, respectively.
You can see opencv2 / opencv3 examples in:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.