You can't create library from one header file:
add_library(ImageFilter itkImageFilter.hxx)
SET_TARGET_PROPERTIES(ImageFilter PROPERTIES LINKER_LANGUAGE CXX)
target_link_libraries(ImageFilter ${ITK_LIBRARIES})
that's the reason why you set LINKER_LANGUAGE
explicitly - there is nothing to link and cmake is confused.
So include_directories
is enough:
include_directories(${PROJECT_SOURCE_DIR}/lib)
BTW:
You don't need to check ITK_FOUND
if you specify REQUIRED
:
FIND_PACKAGE (ITK REQUIRED)
IF( ITK_FOUND )
include( ${ITK_USE_FILE} )
ENDIF( ITK_FOUND )
from documentation:
The REQUIRED option stops processing with an error message if the package cannot be found.
PROJECT_SOURCE_DIR
is not necessary equal itkNormals_SOURCE_DIR
(you may use this file from other project):
include_directories(${PROJECT_SOURCE_DIR}/lib)
Can be fixed one of this way:
include_directories(${itkNormals_SOURCE_DIR}/lib)
include_directories(${CMAKE_CURRENT_LIST_DIR}/../lib)
or simply include from parent file:
# src/CMakeLists.txt
include_directories("./lib")
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…