ʱ�䣺2014/10/28 16:02:22��Դ��www.pc6.com���ߣ�gm��Ҫ����(0)
CMake��һ����make�����ı������ù��ߣ������Ը��ݲ�ͬƽ̨����ͬ�ı�������������Ӧ��Makefile����vcproj��Ŀ��
ͨ����дCMakeLists.txt�����Կ������ɵ�Makefile���Ӷ����Ʊ������̡�CMake�Զ����ɵ�Makefile��������ͨ��make�������Ŀ����Ŀ���ļ�����֧�ְ�װ��make
install��������װ�ij����Ƿ�����ȷִ�У�make test������ctest�������ɵ�ǰƽ̨�İ�װ����make package��������Դ������make
package_source��������Dashboard��ʾ���ݲ��ϴ��ȸ����ܣ�ֻҪ��CMakeLists.txt�м������ã��Ϳ������ɺܶิ�ӵĹ��ܣ�����д����������
������Ƕ��Ŀ¼����Ŀ¼�¿������Լ���CMakeLists.txt��
��֮��CMake��һ���dz�ǿ���ı����Զ����ù��ߣ�֧�ָ���ƽ̨��KDEҲ�����������ģ�����Ȥ�Ŀ�������һ�¡�
�����
��1����װcmake��
| �������ƣ� | CMake���빤��v3.17.2�ٷ��� |
| �������� | 25.3M |
| ���ص�ַ�� | http://www.pc6.com/softview/SoftView_126263.html |
��2������cmake�ķ�������GUI�������У�
http://www.cmake.org/cmake/help/runningcmake.html
CMakeʹ�ò��裺
����GUI��cmake���棺
cmake-2.8.1-win32-x86\bin\cmake-gui.exe
![]()
ִ��Configure��
����֮���������������ļ���
![]()
����Makefile��
ִ��Generate֮�����������ļ���
![]()
����make���б��룺
![]()
�������ɺ�����buildĿ¼����Tutorial.exe������Tutorial.exe 25�Ϳ��Կ������н�����
![]()
����make install��װ������
![]()
����make test���в��ԣ�
![]()
ͨ��cmake tutorialѧϰCMake���÷���http://www.cmake.org/cmake/help/cmake_tutorial.html
������Դ������Tests/TurorialĿ¼���ҵ������ֲ���Ӧ�Ĵ��롣
![]()
1��Step1��
��������֪������ʹ��cmake���Լ�����ʹ�ñ���������Turorial.exe�����ȿ���ǰ�桰CMakeʹ�ò��衱��˵��������Step4Ϊ����ϸ������ʹ�ù��̣�Step1�����ÿ��ܲ�����ȫ������������make
install��������make test�������Բο�����
�ij������롣
��1������GUI��cmake��ָ��Ҫ������Դ����·���Ͷ������ļ�·�������Զ���������
![]()
��2������Configure�����óɹ������ٵ���Generate��
������Ҫѡ�����ʵı���������Ȼ�Ұ�װ��VC2008����û�����óɹ���ѡ��Unix Makefiles�����óɹ������Զ��ҵ���DevC++�µ�gcc.exe�ȱ�������
![]()
��3����build3Ŀ¼ִ��make�����ܹ���������Turorial.exe�ˡ�
D:\Projects\Lab\testngpp\cmake-2.8.1\Tests\Tutorial\Step1\build3>makeLinking CXX executable Tutorial.exe
[100%] Built
target Tutorial
��������һ��Turorial.exe��
D:\Projects\Lab\testngpp\cmake-2.8.1\Tests\Tutorial\Step1\build3>Tutorial.exe
Tutorial.exe
Version 1.0
Usage: Tutorial.exe
number
D:\Projects\Lab\testngpp\cmake-2.8.1\Tests\Tutorial\Step1\build3>Tutorial.exe
4
The square root of 4 is
2
2��Step2����Ŀ¼����Ϊ�⣬�������ӵ����յĿ�ִ���ļ���
include_directories ("${PROJECT_SOURCE_DIR}/MathFunctions")
add_subdirectory (MathFunctions) #
ʹ����Ŀ¼MathFunctionsҲ�ܱ�����
# add the executable
add_executable (Tutorial
tutorial.cxx)
target_link_libraries (Tutorial
MathFunctions)
����makefile��
��GUI�ϵ���Configure��֮��Generate���ǻ�ɫ���ٴε���Configure��Generate�Ϳ��Ե����ˡ�
���룺
��buildĿ¼����make�����ɿ�ʼ���룬���ǿ�ʼ�ᱨ��sh.exe�����쳣��Ӧ����Tools�µ�UnxUtils��sh.exe��Win7�����ݣ�����������make�ļ��������������µģ����ǰ�������������ʹ��UnxUtils�µ�make����OK�֡�
D:\Tools\CMD\UnxUtils\usr\local\wbin\make.exe
�������̣�
D:\Projects\Lab\testngpp\cmake-2.8.1\Tests\Tutorial\Step2\build>make
[
50%] Building CXX object
MathFunctions/CMakeFiles/MathFunctions.dir/mysqrt.cxx
.obj
Linking CXX
static library libMathFunctions.a
[ 50%] Built target
MathFunctions
Linking CXX executable Tutorial.exe
[100%] Built target
Tutorial
3��Step3
֧��make install�ѳ�����װ��ϵͳָ��Ŀ¼����������һЩ���Լ������Ƿ��ܹ�����������
a����װʱʹ�õĻ���Ŀ¼����CMAKE_INSTALL_PREFIXָ����
b������ͨ��һ���ܼ��������������Ƿ�����������û�г����쳣����TurotialRunsֻ��һ���������֣�
add_test (TutorialRuns Tutorial 25)
c��macro��ʽ���ж������ݵIJ����Ƿdz�������ġ�
#define a macro to simplify adding tests, then use it
macro (do_test arg
result)
add_test (TutorialComp${arg} Tutorial ${arg})
set_tests_properties (TutorialComp${arg}
PROPERTIES
PASS_REGULAR_EXPRESSION ${result})
endmacro (do_test)
# do a bunch of result based tests
do_test (25 "25 is 5")
do_test
(-25 "-25 is 0")
ִ��make
install��
D:\Projects\Lab\testngpp\cmake-2.8.1\Tests\Tutorial\Step3\build>make
install
[ 50%] "Built target MathFunctions"
[100%] "Built target
Tutorial"
Install the project...
-- Install configuration: ""
--
Installing: C:/Program Files/Tutorial/bin/Tutorial.exe
-- Installing:
C:/Program Files/Tutorial/include/TutorialConfig.h
-- Installing: C:/Program
Files/Tutorial/bin/libMathFunctions.a
-- Installing: C:/Program
Files/Tutorial/include/MathFunctions.h
��װ������C:\Program
Files\Tutorial>tree /f
C:.
����bin
�� libMathFunctions.a
��
Tutorial.exe
��
����include
MathFunctions.h
TutorialConfig.h
ִ��make
test��
D:\Projects\Lab\testngpp\cmake-2.8.1\Tests\Tutorial\Step3\build>make
test
Running tests...
Test project
D:/Projects/Lab/testngpp/cmake-2.8.1/Tests/Tutorial/Step3/build
Start 1:
TutorialRuns
1/5 Test #1: TutorialRuns ..................... Passed 0.01
sec
Start 2: TutorialComp25
2/5 Test #2: TutorialComp25
................... Passed 0.01 sec
Start 3: TutorialNegative
3/5 Test
#3: TutorialNegative ................. Passed 0.01 sec
Start 4:
TutorialSmall
4/5 Test #4: TutorialSmall .................... Passed 0.00
sec
Start 5: TutorialUsage
5/5 Test #5: TutorialUsage
.................... Passed 0.00 sec
100% tests passed, 0 tests failed out of 5
Total Test time (real) = 0.13
sec
��һ����������������������
�Ķ���CMakeLists.txt��Ȼ������Configure��Generate��Ȼ��make
test���ɿ���������
D:\Projects\Lab\testngpp\cmake-2.8.1\Tests\Tutorial\Step3\build>make
test
Running tests...
Test project
D:/Projects/Lab/testngpp/cmake-2.8.1/Tests/Tutorial/Step3/build
Start 1:
TutorialRuns
1/5 Test #1: TutorialRuns ..................... Passed 0.01
sec
Start 2: TutorialComp25
2/5 Test #2: TutorialComp25
...................***Failed Required regular expre
ssion not found.Regex=[25
is 3
] 0.01 sec
Start 3: TutorialNegative
3/5 Test #3:
TutorialNegative ................. Passed 0.01 sec
Start 4:
TutorialSmall
4/5 Test #4: TutorialSmall .................... Passed 0.01
sec
Start 5: TutorialUsage
5/5 Test #5: TutorialUsage
.................... Passed 0.01 sec
80% tests passed, 1 tests failed out of 5
Total Test time (real) = 0.13 sec
The following tests FAILED:
2 - TutorialComp25
(Failed)
Errors while running CTest
make: *** [test] Error
8
4��Step4
����ϵͳ�Ƿ�֧��log��exp��������log��exp������ѧ���㺯����
���鷽����
��1������������ʹ��CheckFunctionExists.cmake
# does this system provide the log
and exp functions?
include
(CheckFunctionExists.cmake)
check_function_exists (log
HAVE_LOG)
check_function_exists (exp
HAVE_EXP)
��2����.in�ļ��������ꡣ����TutorialConfig.h.in��cmakeִ���л��Ѻ궨��Ϊ���ʵ�ֵ������TurorialConfig.h��������ʱʹ�ã�
//
does the platform provide exp and log functions?
#cmakedefine
HAVE_LOG
#cmakedefine HAVE_EXP
��3���ڴ�����ʹ�ú���log�����ȡ�
// if we have both log and exp then use them
#if defined (HAVE_LOG)
&& defined (HAVE_EXP)
result = exp(log(x)*0.5);
#else //
otherwise use an iterative approach
Step4���������á�����Makefile�����롢���С���װ�����Թ��̣��μ���ǰ���ġ�CMakeʹ�ò��衱��
5��Step5
��̬����Դ�ļ����Զ���Դ�ļ�������ϵͳ�С�
make��ʱ�������ˣ�D:\Projects\Lab\testngpp\cmake-2.8.1\Tests\Tutorial\Step5\build>make
Scanning
dependencies of target MakeTable
[ 25%] Building CXX object
MathFunctions/CMakeFiles/MakeTable.dir/MakeTable.cxx.
obj
Linking CXX
executable MakeTable.exe
[ 25%] "Built target MakeTable"
[ 50%] Generating
Table.h
'.' �����ڲ����ⲿ���Ҳ���ǿ����еij���
�����������
make[2]: ***
[MathFunctions/Table.h] Error 1
make[1]: *** [MathFunctions/CMakeFiles/MathFunctions.dir/all] Error
2
make: *** [all] Error 2
����������
���ȿ�build/makefile�ļ�������MakeTable�����¹�����
# Build rule for target.
MakeTable:
cmake_check_build_system
$(MAKE) -f CMakeFiles/Makefile2
MakeTable
.PHONY : MakeTable
�ٿ�Makefile2�ļ����ҵ�����ʱ���ڱ�����Ŀ�ꡣ
# All Build rule for target.
MathFunctions/CMakeFiles/MakeTable.dir/all:
$(MAKE)
-f MathFunctions/CMakeFiles/MakeTable.dir/build.make
MathFunctions/CMakeFiles/MakeTable.dir/depend
$(MAKE) -f
MathFunctions/CMakeFiles/MakeTable.dir/build.make
MathFunctions/CMakeFiles/MakeTable.dir/build
$(CMAKE_COMMAND) -E
cmake_progress_report
D:/Projects/Lab/testngpp/cmake-2.8.1/Tests/Tutorial/Step5/build/CMakeFiles
1
@echo "Built target MakeTable"
.PHONY :
MathFunctions/CMakeFiles/MakeTable.dir/all
Make������ִ��˳���ǰ����������Ⱥ�˳����
����Makefile�������£�
all:
echo "First line."
echo "Second
line."
��ômake������
D:\Users\Desktop>make
echo "First line."
First
line.
echo "Second line."
Second line.
�ɴˣ�Built target MakeTable����֮����ʧ�ܵġ�
6��Step6
���ɸ���ƽ̨Windows/Ubuntu/etc.�ϵİ�װ�������������ư�װ����Դ�밲װ����
����������ϵͳ��Ҳ������include (InstallRequiredSystemLibraries)
ʹ��CPack��
����Step1-7������һ�������ö�������ǰ��һ�������ã����Դ�Step5��ʼ���ͻ�����make�����⡣
Ϊ�˱���ͨ����������MathFunctionsĿ¼�µ�CMakeLists.txt��mysqrt.cxx��ȥ�����ж�Table.h ��������
����make package�������ɰ�װ����
��һ�Σ���Ϊû�а�װnsis����ʾ�������⣺
D:\Projects\Lab\testngpp\cmake-2.8.1\Tests\Tutorial\Step6\build>make
package
[ 50%] "Built target MathFunctions"
[100%] "Built target
Tutorial"
Run CPack packaging tool...
CPack Error: Cannot find NSIS
registry value. This is usually caused by NSIS not
being installed. Please
install NSIS from http://nsis.sourceforge.net
CPack Error: Cannot initialize
the generator NSIS
make: *** [package] Error 1
��װNSIS֮�������гɹ���
D:\Projects\Lab\testngpp\cmake-2.8.1\Tests\Tutorial\Step6\build>make
package
[ 50%] "Built target MathFunctions"
[100%] "Built target
Tutorial"
Run CPack packaging tool...
CPack: Create package using
NSIS
CPack: Install projects
CPack: - Run preinstall target for:
Tutorial
CPack: - Install project: Tutorial
CPack: Compress
package
CPack: Finalize package
CPack: Package
D:/Projects/Lab/testngpp/cmake-2.8.1/Tests/Tutorial/Step6/build/T
utorial-1.0.1-win32.exe
generated.
���������µ�Windows��װ���ļ���
![]()
��װ���ɺ����Ժܷ�����ж������
![]()
����make
package_source���Բ���Դ�����������ҵĵ�������ʾ�Ҳ������ʵ�zip������
D:\Projects\Lab\testngpp\cmake-2.8.1\Tests\Tutorial\Step6\build>make
package_sou
rce
Run CPack packaging tool for source...
CPack Error:
Cannot find a suitable ZIP program
CPack Error: Cannot initialize the
generator ZIP
make: *** [package_source] Error 1
7��Step7
�ѽ���������dashboard��
������ַ��һ��������dashboard��
http://www.cdash.org/CDash/index.php?project=PublicDashboard
![]()
dashboard����ʾ����Ŀ����ͨ�����·�ʽ���ã�
![]()
��Ҫ�Ȱ�cmake\binĿ¼����path�У�Ȼ��ִ��ctest -D Experimental������������һ��������
D:\Projects\Lab\testngpp\cmake-2.8.1\Tests\Tutorial\Step7\build>ctest -D
Experim
ental
Site: JELLY-PC2
Build name: Win32-make
Create
new tag: 20100521-1833 - Experimental
Configure project
Each .
represents 1024 bytes of output
. Size of output: 0K
Build
project
Each symbol represents 1024 bytes of output.
'!' represents
an error and '*' a warning.
. Size of output: 0K
0 Compiler
errors
0 Compiler warnings
Test project
D:/Projects/Lab/testngpp/cmake-2.8.1/Tests/Tutorial/Step7/build
Start 1:
TutorialRuns
1/9 Test #1: TutorialRuns ..................... Passed 0.01
sec
Start 2: TutorialUsage
2/9 Test #2: TutorialUsage
.................... Passed 0.01 sec
Start 3: TutorialComp4
3/9 Test
#3: TutorialComp4 .................... Passed 0.01 sec
Start 4:
TutorialComp9
4/9 Test #4: TutorialComp9 .................... Passed 0.01
sec
Start 5: TutorialComp5
5/9 Test #5: TutorialComp5
.................... Passed 0.01 sec
Start 6: TutorialComp7
6/9 Test
#6: TutorialComp7 .................... Passed 0.01 sec
Start 7:
TutorialComp25
7/9 Test #7: TutorialComp25 ................... Passed 0.01
sec
Start 8: TutorialComp-25
8/9 Test #8: TutorialComp-25
.................. Passed 0.01 sec
Start 9: TutorialComp0.0001
9/9
Test #9: TutorialComp0.0001 ............... Passed 0.01 sec
100% tests passed, 0 tests failed out of 9
Total Test time (real) = 0.19 sec
Performing coverage
Cannot
find any coverage files. Ignoring Coverage request.
Submit files (using
http)
Using HTTP submit method
Drop site:http://
Error when
uploading file:
D:/Projects/Lab/testngpp/cmake-2.8.1/Tests/Tutoria
l/Step7/build/Testing/20100521-1833/Build.xml
Error message was: couldn't connect to host
Problems when submitting via
HTTP
Errors while running CTest
����������һЩ�ļ���
![]()
������Ƶ
�����Ķ� ����������ǿFlash�����빤���÷����빤�������õ�����ԭ�α�¶��Chrome���������ϰ汾������װ�̳� �ȸ����������ϰ汾������װ��macOS 10.15��ô���� macOS 10.15�����̳�macOS 10.15֧����Щ�豸���� macOS Catalina�������豸һ��macOS 10.15��ʲô�¹��� macOS Catalina�¹�����ϸ���������Ͱ��ջ�����ô��װ �����Ͱ��ջ����尲װ�̳�word clock Mac����ô�� ����ʱ��word clock��ô����
��������
�����ƽ�����ʵ���̳�
��������
CMake��װʹ�ý̳�
�����ƽ�����ʵ���̳�
Unity3D���Ž̳�����ͼ��smart install makerʵ��ͼ�Ľ̳������ƽ�����ʵ���̳�(�����߸�ͼ)ansys10.0��װ����ͼ�Ľ̳�+��Ƶ
�������� �����ƽ�����ʵ���̳�(�����߸�ͼ)��ģ������ô�� ����X3ͼ��ʹ�ý̳���Ƭ��ģ����������proteus��װ�̳�ͼ������ģ������װͼ���̳������õİ���(chm)�ļ����������Ƽ�CMake��װʹ�ý̳�Unity3D���Ž̳�����ͼ��xpϵͳ���棨android�����ֻ�ˢ��ROM�̳�
�鿴����0������>>