# first we add the executable that generates the table
add_executable(MakeTable MakeTable.cxx)
# add the command to generate the source code
add_custom_command (
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Table.h
DEPENDS MakeTable
COMMAND MakeTable
ARGS ${CMAKE_CURRENT_BINARY_DIR}/Table.h
)
set_source_files_properties (
mysqrt.cxx PROPERTIES
OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Table.h
)
# add the binary tree directory to the search path for include files
include_directories( ${CMAKE_CURRENT_BINARY_DIR} )
# add the main library
add_library(MathFunctions mysqrt.cxx)
set_target_properties(MathFunctions
PROPERTIES TEST "Hello")
get_target_property(TEST MathFunctions TEST)
message("-------------------------")
message(${TEST})
message("-------------------------")
set_target_properties()는 특정 target에 속성을 부여하는 명령어이다.
set_target_properties(MathFunctions
PROPERTIES TEST "Hello")
add_library()로 빌드되어지는 MathFunctions library 에 TEST 라는 속성을 부여하여 "Hello" 값을 저장한다.
이후 get_target_property()를 통해 속성 값을 읽어 올 수 있다.
get_target_property(OUT1 MathFunctions TEST)
message("-------------------------")
message(${OUT1})
message("-------------------------")
cmake 를 통해 실행 결과를 살펴보면, 아래와 같이 set_target_properties로 저장한 값 "Hello"가 출력되는 것을 볼 수 있다.
set_target_properties() / get_target_property() 또한 set_property() / get_property()를 사용하여 동일한 기능을 수행할 수 있다.
//Case#1
set_target_properties(MathFunctions
PROPERTIES TEST "Hello")
get_target_property(OUT1 MathFunctions TEST)
//Case#2
set_property(TARGET MathFunctions PROPERTY TEST1 "Hi")
get_property(OUT2 TARGET MathFunctions PROPERTY TEST1)
message("-------------------------")
message(${OUT1})
message(${OUT2})
message("-------------------------")
Case#1과 Case#2 결과 모두 동일한 것을 알 수 있다.
[CMAKE] Cache 변수 (0) | 2024.06.26 |
---|---|
[CMAKE] include() (0) | 2024.06.26 |
[CMAKE] set_source_files_properties() / get_source_file_property() (0) | 2021.11.03 |
[CMAKE] find_path() ( 환경변수 참조.. ) (0) | 2021.11.03 |
[CMAKE] file() (0) | 2021.11.03 |