CMake - add_library, target_link_libraries

markyang92·2024년 9월 3일
0

cmake

목록 보기
2/2
post-thumbnail

소스파일


CMakeLists.txt

add_library(): 라이브러리 생성

 add_library(<name> [STATIC | SHARED | MODULE]
             [EXCLUDE_FROM_ALL]
             [<source>...])

Adds a library target called ``<name>`` to be built from the source files
listed in the command invocation.  The ``<name>``
corresponds to the logical target name and must be globally unique within
a project.  The actual file name of the library built is constructed based
on conventions of the native platform (such as ``lib<name>.a`` or
``<name>.lib``).

Specify libraries or flags to use when linking a given target and/or
its dependents.  :ref:`Usage requirements <Target Usage Requirements>`
from linked library targets will be propagated.  Usage requirements
of a target's dependencies affect compilation of its own sources.

Overview
^^^^^^^^

This command has several signatures as detailed in subsections below.
All of them have the general form

 target_link_libraries(<target> ... <item>... ...)

The named ``<target>`` must have been created by a command such as
``add_executable()`` or ``add_library()`` and must not be an
:ref:`ALIAS target <Alias Targets>`.  If policy ``CMP0079`` is not
set to ``NEW`` then the target must have been created in the current

Library, Executable 만 빌드해보자

  • 위의 'Library'에 대해서만 빌드
$ cmake --build . --target Library

  • 위의 'Executable'에 대해서만 빌드
$ cmake --build . --target Executable
profile
pllpokko@alumni.kaist.ac.kr

0개의 댓글