| Line 303: | Line 303: | ||
:''Use ADD_CUSTOM_COMMAND(). It's explained here in the CMake wiki: [http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_generate_a_source_file_during_the_build.3F How can I generate a source file during the build]'' | :''Use ADD_CUSTOM_COMMAND(). It's explained here in the CMake wiki: [http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_generate_a_source_file_during_the_build.3F How can I generate a source file during the build]'' | ||
| + | === 생성할 파일을 빌드하는 동안 나중에 사용할 실행 파일을 빌드하는 것이 필요하다. 어떻게 해야 합니까? === | ||
=== I need to build an executable which is used later on during the build to generate files. How do I do this ? === | === I need to build an executable which is used later on during the build to generate files. How do I do this ? === | ||
Let's say the executable is called genembed. Then use KDE4_ADD_EXECUTABLE(foo RUN_UNINSTALLED ${fooSources})to create the executable. The RUN_UNINSTALLED option is important, because the executable has to run from the build dir and has to link to the libraries in the builddir. To achieve this, the executable is compiled with RPATH set accordingly and a wrapper shell script, named just like the executable but with the suffix ".sh" is created. This shell scripts sets up LD_LIBRARY_PATH and the calls the actual executable. | Let's say the executable is called genembed. Then use KDE4_ADD_EXECUTABLE(foo RUN_UNINSTALLED ${fooSources})to create the executable. The RUN_UNINSTALLED option is important, because the executable has to run from the build dir and has to link to the libraries in the builddir. To achieve this, the executable is compiled with RPATH set accordingly and a wrapper shell script, named just like the executable but with the suffix ".sh" is created. This shell scripts sets up LD_LIBRARY_PATH and the calls the actual executable. | ||
| Line 322: | Line 323: | ||
</code> | </code> | ||
| − | As you can see genembed is also listed as a dependency, this means cmake knows that it has to build the executable genembed before executing this rule. | + | :''As you can see genembed is also listed as a dependency, this means cmake knows that it has to build the executable genembed before executing this rule. |
| − | === | + | === -DCMAKE_INSTALL_PREFIX 커맨드 라인 옵션을 설정하는 것을 원하지 않는다. cmake에서 KDEDIR 환경 변수를 지원하는가? === |
| − | No. $KDEDIR is deprecated in KDE 4. | + | 아니오. $KDEDIR은 KDE4에서 반대되어지고 있다. |
| + | :''No. $KDEDIR is deprecated in KDE 4.'' | ||
| − | === | + | === 왜 /usr/lib/qt4/include/QtCore/qstring.h:536: undefined reference to 'QString::fromLatin1_helper(char const*, int)'와 같은 에러가 나는가? === |
| − | A: If you have an old Qt4 version in your qt/lib directory you must delete the old (4.0.1) files. | + | 만약 qt/lib 디렉토리에 오래된 Qt4 버전을 가졌다면, 당신은 오래된 버전(4.0.1)을 지워야한다. |
| + | :''A: If you have an old Qt4 version in your qt/lib directory you must delete the old (4.0.1) files.'' | ||
| − | === | + | === 시끄러운 makefile을 생성하기 위해서는 어떻게 cmake를 사용해야 하는가? 나는 make과정 중에 실행되는 정확한 명령어들을 볼 수 있기를 원한다.=== |
| − | Pass the VERBOSE variable to make, i.e. | + | make할때 VERBOSE 변수를 포함하라. 예를 들어: |
| + | :''Pass the VERBOSE variable to make, i.e.'' | ||
<code> | <code> | ||
% make VERBOSE=1 | % make VERBOSE=1 | ||
| Line 340: | Line 344: | ||
</code> | </code> | ||
| − | For more details see the CMake wiki: [http://www.cmake.org/Wiki/CMake_FAQ#Is_there_an_option_to_produce_more_.27verbose.27_compiling.3F Is there an option to produce more 'verbose' compiling?] | + | 좀 더 자세한 사항은 CMake 위키를 살펴보라. |
| + | [http://www.cmake.org/Wiki/CMake_FAQ#Is_there_an_option_to_produce_more_.27verbose.27_compiling.3F Is there an option to produce more 'verbose' compiling?] | ||
| + | :''For more details see the CMake wiki: '' | ||
| + | [http://www.cmake.org/Wiki/CMake_FAQ#Is_there_an_option_to_produce_more_.27verbose.27_compiling.3F Is there an option to produce more 'verbose' compiling?] | ||
| − | === | + | === 생성된 Makefile에 'make distclean'이 존재하지 않는다. cache파일을 포함하여 모든 것을 지우려면 어떻게 해야 하는가? === |
| − | Simply remove the build directory, or just the contents of the build directory. | + | 간단하게 빌드 디렉토리를 지우거나 혹은 빌드 디렉토리의' 컨텐츠를 지워라. |
| + | :'Simply remove the build directory, or just the contents of the build directory.'' | ||
[[Category:Programming]] | [[Category:Programming]] | ||
[[Category:Tutorial]] | [[Category:Tutorial]] | ||
[[Category:FAQs]] | [[Category:FAQs]] | ||
Languages: عربي | Asturianu | Català | Česky | Kaszëbsczi | Dansk | Deutsch | English | Esperanto | Español | Eesti | فارسی | Suomi | Français | Galego | Italiano | 日本語 | 한국어 | Norwegian | Polski | Português Brasileiro | Română | Русский | Svenska | Slovenčina | Slovenščina | српски | Türkçe | Tiếng Việt | Українська | 简体中文 | 繁體中文
CMake는 스크립트 파일을 읽고, 그것이 실행되는 플랫폼의 native 빌드 시스템의 위해 input 파일들을 생성한다. 이것은 GNU Makefile, KDevelop 프로젝트파일, XCode 프로젝트 파일, 그리고 Visual Studio 프로젝트 파일을 생성할수 있다.
CMake는 자유 소프트웨어이고, BSD-style 라이센스 한에서 릴리즈된다. 이것은 Kitware Inc.에 의해 개발되었다.
아래의 링크들은 일반적으로 CMake에 대해 배울수 있는 몇몇 괜찮은 곳들이다.:
Here are some good places to learn about CMake in general:
또한 CMake 메일링 리스트에 가입하는 것을 고려해보라.
CMake는 2006년 3월에 결정된 KDE 4 release의 공식적인 도구이다. 첫번째로 오래된 KDE 도구 automake와 unsermake와 비교하여 기술적인 장점때문이다.:
CMake is the official tool of KDE 4 release, decided in March 2006, primarily due to technical merits as compared to the older KDE tools automake and unsermake:
[1]에서 CMake의 마지막 버전을 검색한다.
다운로드 하여 압축을 풀고, 컴파일 한다.:
$ mkdir cmake-build
$ cd cmake-build
$ ../bootstrap
$ make
$ make install
기본적으로 이것은 CMake를 /user/local 안에 설치할 것이다. 그러므로 당신의 실행 경로 안에/user/local/bin을 가지고 있도록 해야한다. 만약 설치 prefix를 바꾸려면, (예를 들어 데비안에서는 /usr로), '--prefix=PATH' 옵션을 bootstrap 명령에 추가하라.
만약 현재 개발버전을 사용하기를 원한다면, here에 위치한 설명에 따르라.
[3]에서 CMake의 가장 마지막 안정 버전을 검색하라.
다운로드받아서 cmake 인스톨러를 설치하라.
기본적으로 이것은 C:\Program Files\CMake 2.4에 설치될 것이다. 그러므로 당신의 실행 경로에 <installpath>\bin를 추가시켜야 한다.
만약 현재 개발 버전을 사용하기를 원한다면, here의 설명에 따르라.
당신의 시스템을 위해 빌드 파일들을 생성하기 위해서는 CMake를 실행해야 한다. in-source(소스 안에서)와 out-of-source(소스 밖에서) 둘 다 CMake에 의해 지원된다. 그러나 현재 in-source(소스 안에서) 빌드는 KDE 구현에 의하여 막혀져 있다.
그러므로 ~/src/kdelibs/ 안에 kdelibs/를 가지고 있다고 한다면, 다음을 수행한다.
$ ls
kdelibs/
$ mkdir kdelibs-build
$ cd kdelibs-build
$ cmake ../kdelibs
이것은 kdelibs-build/ 안에 kdelibs의 빌드를 위해 Makefile을 생성할 것이다.
당신의 시스템을 위해 빌드 파일들을 생성하기 위해서는 CMake를 실행해야 한다. in-source(소스 안에서)와 out-of-source(소스 밖에서) 둘 다 CMake에 의해 지원된다. 그러나 현재 in-source(소스 안에서) 빌드는 KDE 구현에 의하여 막혀져 있다.
c:\daten\kde4 안에 kdelib\를 가지고 있다고 한다면, 다음을 수행한다.:
c:\daten\kde4> cd kdelibs\win
c:\daten\kde4> cmake
c:\daten\kde4> make
c:\daten\kde4> make install
c:\daten\kde4> cd ..
c:\daten\kde4> mkdir kdelibs-build
c:\daten\kde4> cd kdelibs-build
c:\daten\kde4\kdelibs-build> cmake ..\kdelibs
이것은 kdelibs-build/ 안에 kdelibs의 빌드를 위해 Makefile을 생성할 것이다. 윈도우에서 KDE 컴파일에 관한 정보를 얻고 싶다면, KDE on Windows를 참고하라.
만약 (기본적으로 KDevelop를 위한 몇몇 파일에 의해 Makefile이 동반되는)KDevelop를 위한 프로젝트 파일을 좋아한다면, 이것과 같이 실행하라.
$ cmake ../kdelibs -GKDevelop3
CMake가 지원하는 것과 다른 옵션을 찾기 위해 'cmake -h'를 사용하라.
Qt 4에 위치한 곳을 찾아내기 위해, CMake는 당신의 실행 경로에서 qmake를 찾는다. CMake는 QTDIR 환경 변수를 사용하지 않는다. 그러므로, 실행 경로에서 찾은 처음 qmake가 사용하기 원하는 것인지 확인하라.
CMake가 종료되었을 때, "CMakeCache.txt"라는 파일이 생성될 것이다. 이것은 당신의 시스템에서 CMake가 찾은 모든 설정을 포함한다. 만약 다른 생성 프로그램으로 CMake를 수행하기를 원하거나, CMake가 모든 것을 다시 찾기를 원한다면 이 파일을 지워라.
만약 CMake가 무언가를 찾지 않았지만, 당신이 이것이 당신의 상자의 어딘가에 있다는 것을 안다면, 당신은 CMake에게 찾을 곳을 수동적으로 알려줄 수 있다. CMake는 이 정보를 저장하는 변수를 사용한다. 이 변수들은 이미 언급된 CMakeCache.txt 파일에 캐시된다. 이 변수들을 수동적으로 적용하기 위해 3가지 방법이 있다.
당신은 최소한 한번은 "ccmake ../kdelibs"를 실행해야 한다. 그래서 CMake가 사용하는 변수의 결과물을 얻는다. "T"를 누르고 "advanced" 변수를 보기 위해 "T"를 눌러라. 그래서 CMake가 아무것도 찾지 않았다면, ccmake를 시작하고, 수동적으로 그것을 적용하라.
당신이 설정하기 원할 수 있는 cmake 커맨드라인 변수들:
Some cmake command line variables you may want to set:
만약 cmake가 찾지 못하는 비 표준 위치(예 를들어 Mac OSX의 fink가 /sw에 설치되었다면)에 설치된 헤더와 라이브러리를 가지고 있다면, 환경변수로써 다음과 같은 것들을 설정한다. 비슷한 네이밍 규약임에도 불구하고, cmake 커맨드라인에서 인자처럼 동작하지 않을 것이다. : If you have headers and libraries installed in non-standard locations that cmake cannot find (e.g., fink on Mac OSX installs to /sw), then set the following as environment variables. Despite the similar naming convention, these will not work as arguments on the cmake command line:
대하여 더 많은 정보를 얻으려면, this cmake.org 위키 페이지를 살펴보라.
만약 cmake가 "Generating done"메세지와 함께 완료되었다면, 에러가 존재하지 않는다. 그러나 만약 "Configuring done" 메세지로 완료되었다면, 당신이 고쳐야할 에러가 존재한다. cmake가 성공적으로 종료하면, (예를 들어, make, KDevelop, XCode 또는 MSVC) 빌드 툴을 실행하고 빌드하라 그리고 끝날 때까지 기다려라. 그리고 "make install"하라.
만약 다음과 같은 실패를 얻었다면
CMake Error: This project requires some variables to be set,
and cmake can not find them.
Please set the following variables:
X11_XTest_LIB (ADVANCED)
당신은 빠진 라이브러리(또는 다른 의존성)를 갖을 것이다. 어떤 라이브러리인지 찾기 위해, cmake/modules 디렉토리에서 cmake가 찾을 수 없는 변수를 검색하라. 위의 예제의 경우, 이것은:
out which library, search in the cmake/modules directory for
the variable that cmake can't find. In the example above, it is
FIND_LIBRARY(X11_XTest_LIB Xtst ${X11_LIB_SEARCH_PATH})
그러므로 빠진 라이브러리는 Xtst이다. 이것을 찾을 필요가 있으며(아마 libXtst-devel 라이브러리로 설치된다.) , cmake를 재실행해야한다.
여기 가장 간단한 CMakeList.txt파일이 있다.:
add_executable(hello main.cpp)
이것은 소스파일인 main.cpp에서 "hello"(윈도우에서는 "hello.exe")라는 실행 파일을 생성한다. 당신이 원하는 C와 C++ 파일을 섞을 수 있다. 당신은 하나의 CMakeList.txt 파일 안에서 여러 개의 실행파일과 라이브러리를 가질 수 있다. 같은 소스 파일은 다양한 타겟에서 사용가능하다. 그리고 이것은 각각의 타겟을 위해 다른 타겟과는 독립적으로 컴파일되어질 것이다. 아마도 cmake의 가장 중요한 부분은 변수들이다.:
SET( MY_SOURCES main.cpp widget.cpp)
MESSAGE(STATUS "my sources: ${MY_SOURCES}")
그러므로 변수의 값을 설정하기 위해 SET() 명령어를 사용할 수 있다. 만약 하나의 문자열보다 더 많이 목록화한다면, 그 변수는 하나의 리스트가 될 것이다. 하나의 리스트는 세미콜론(;)에 의해 나누어지는 문자열의 리스트이다. 만약 단지 하나의 아이템을 설정하였다면, 이것은 단지 값이 될 것이다. 변수의 값을 얻기 위해 ${VAR}를 사용한다. FOREACH()랄 사용하여 리스트를 iterate가 가능하다.
You can iterate over a list using FOREACH():
FOREACH(next_ITEM ${MY_SOURCES})
MESSAGE(STATUS "next item: ${next_ITEM}")
ENDFOREACH(next_ITEM ${MY_SOURCES}) CMake의 명령어들은 대소문자를 구분하지 않아도된다. 변수의 이름과 파라미터의 이름은 대소문자를 구별해야 한다.
또한 당신은 다양한 것들을 위한 테스트를 할 수 있다.:
IF (UNIX)
MESSAGE(STATUS "This is UNIX (including OS X and CygWin)")
ENDIF (UNIX)
IF (MSVC)
SET(MY_SRCS ${MY_SRCS} winextra.cpp)
ENDIF (MSVC) 이 두번째 예제에서는 리스트로 아이템을 어떻게 추가하는지 보여준다.
cmake 위키에 튜트리얼가 존재한다. 이것은 KDE 4 소프트웨어를 어떻게 빌드하는지에 대하여 설명한다. 읽는 것을 추천한다.
여기에 하나의 작은 KDE 4 프로젝트를 빌드하는 기본 CMakeList 파일이 있다.
PROJECT(kde4project)
FIND_PACKAGE(KDE4 REQUIRED)
INCLUDE_DIRECTORIES( ${KDE4_INCLUDES} )
SET(KDE4ProjectSources kde4mainapp.cpp someclass.cpp someotherclass.cpp)
KDE4_ADD_EXECUTABLE(kde4project ${KDE4ProjectSources} )
TARGET_LINK_LIBRARIES(kde4project ${KDE4_KDEUI_LIBS} ${KDE4_KPARTS_LIBS} ) 변수, 매크로, KDE에서 다른 유용한 특정 정보들은 Development/KDE and CMake Together (ko) 페이지에서 찾을 수 있다.
CMake는 cmake 스크립트를 사용하여 확장할 수 있다. CMake는 많은 스크립트를 가지고 있다.; 유닉스 아래에서 그것들은 /usr/local/share/CMake/Modules/에 기본적으로 설치된다. 또한 KDE 라이브러리들은 share/apps/cmake/modules/ 안에 cmake 모듈들을 인스톨한다. 시스템 적역 cmake 모듈 경로에서 우선적인 하나에 파일은 위치시킨다. 소프트웨어를 검색하기 위한 것은 FindFOO.cmake 파일에 존재한다. 좀더 자세한 사항을 위해서는 여기를 살펴보라. 이것은 당신이 소프트웨어를 빌드하는데 필요할 대부분의 것들을 하기 위해 충분히 강력하다. 그러나 이것들은 일반 프로그래밍 언어에서 사용되도록 의도되어진 것은 아니다.
For detecting software packages there are FindFOO.cmake files, see here for more information. You can also write macros in CMake. They are powerful enough to do most things you will need to build software, but they are not intended to be used as a general purpose programming language.
kdesdk/cmake/ 안에서 am2cmake 스크립트를 찾을 수 있을 것이다. 이것은 루비 스크립트이므로, 루비가 설치되어야 할 필요가 있다. am2cmake를 소스 디렉토리의 최상위 디렉토리에서 실행하자.
$ cd src/mykooltool/
$ am2cmake --kde4
"--kde4" 스위치를 잊지마라", 그렇지 않으면 KDE4 소프트웨어를 위한 적절한 파일을 생성하지 않을 것이다. 변환 파일은 그것들과 같이 '동적할 것이다.' 그러나 복잡한 프로젝트는 몇몇 추가적인 수정이 필요하다.
당신은 아래와 같은 것들을 해야 할 것이다.:
CMake 위키의 CMake 에디터 지원 섹션을 읽어라. 이것은 Emacs(XEmacs도 동작한다.), VIM, Kate, KWrite, 그리고 KDevelop에서 어떻게 설정하는지에 대해 설명한다.
Let's say the executable is called genembed. Then use KDE4_ADD_EXECUTABLE(foo RUN_UNINSTALLED ${fooSources})to create the executable. The RUN_UNINSTALLED option is important, because the executable has to run from the build dir and has to link to the libraries in the builddir. To achieve this, the executable is compiled with RPATH set accordingly and a wrapper shell script, named just like the executable but with the suffix ".sh" is created. This shell scripts sets up LD_LIBRARY_PATH and the calls the actual executable.
Use this wrapper shell script in the ADD_CUSTOM_COMMAND() as described above.
You can find out the name and exact location by querying the property WRAPPER_SCRIPT. Here's a full example taken from kdelibs/kstyles/keramik/ :
KDE4_ADD_EXECUTABLE(genembed RUN_UNINSTALLED ${genembed_SRCS})
GET_TARGET_PROPERTY(GENEMBED_EXECUTABLE genembed WRAPPER_SCRIPT)
ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/keramikrc.h
COMMAND ${GENEMBED_EXECUTABLE} --file ${CMAKE_CURRENT_BINARY_DIR}/keramikPics.txt > \
${CMAKE_CURRENT_BINARY_DIR}/pixmaps.keramik
DEPENDS genembed ${keramikPics}
)
아니오. $KDEDIR은 KDE4에서 반대되어지고 있다.
만약 qt/lib 디렉토리에 오래된 Qt4 버전을 가졌다면, 당신은 오래된 버전(4.0.1)을 지워야한다.
make할때 VERBOSE 변수를 포함하라. 예를 들어:
% make VERBOSE=1
or
% VERBOSE=1 make
좀 더 자세한 사항은 CMake 위키를 살펴보라. Is there an option to produce more 'verbose' compiling?
Is there an option to produce more 'verbose' compiling?
간단하게 빌드 디렉토리를 지우거나 혹은 빌드 디렉토리의' 컨텐츠를 지워라.