특정 cmake가 존재하는지 여부를 확인하기 위해 기본 cmake를 작성하려고합니다. check_type_size를 여러 번 호출하는 데 문제가 있습니다. 동일한 변수 (크기를 보유하는 변수)를 여러 번 사용하면 check_type_size를 호출 할 때만 채워집니다. 4 VAR_SIZE1가 두 번째 호출 이후에 업데이트되지 않은 일을 - INT의 INT 확인 크기의 확인 크기 : 이것은 내가 무엇을 얻을cmake check_type_size 여러 호출에서 같은 변수를 사용할 때 문제가 발생했습니다
cmake_minimum_required(VERSION 3.8)
project(TEST LANGUAGES C;CXX)
INCLUDE (CheckTypeSize)
check_type_size("int" VAR_SIZE1)
message(${VAR_SIZE1})
check_type_size("void *" VAR_SIZE1)
message(${VAR_SIZE1})
message("VAR_SIZE1 was not updated after the second call.\n")
check_type_size("int" VAR_SIZE2)
message(${VAR_SIZE2})
check_type_size("void *" VAR_SIZE3)
message(${VAR_SIZE3})
message("We get the correct size if use different variable every time.")
add_executable(TEST "${TEST_SOURCE_DIR}/main.cpp")
.
Check size of int
Check size of int - done
4
Check size of void *
Check size of void * - done
8
We get the correct size if use different variable every time.
어떤 일이 일어나고 있는지 알 수 있습니까? check_type_size()
호출로 생성
가능한 복제 https://stackoverflow.com/questions/46204710/ cmake-check-function-exists- only-called-one-time-in-macro)를 지원합니다. 그냥 변수 네이밍을 처리하는 자신의 래퍼 매크로에 형식 검사를하십시오. – Florian