Commit 669b1432 authored by Ole Christian Eidheim's avatar Ole Christian Eidheim
Browse files

Modernized cmake files

parent 0ab1692d
cmake_minimum_required (VERSION 2.8.4)
set(project_name clangmm)
project(${project_name})
cmake_minimum_required(VERSION 2.8)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O3 -Wall -Wextra -Wno-unused-parameter")
project(clangmm)
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/Modules")
find_package(LibClang REQUIRED)
add_compile_options(-std=c++11 -Wall -Wextra -Wno-unused-parameter)
if(APPLE)
set(Boost_USE_STATIC_LIBS "YES")
set(CMAKE_MACOSX_RPATH 1)
endif()
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
set(NOT_SUB_PROJECT 1)
endif()
add_subdirectory(src)
option(BUILD_TESTING Off)
# To enable tests: cmake -DBUILD_TESTING=1 ..
option(BUILD_TESTING OFF)
if(${NOT_SUB_PROJECT})
set(BUILD_TESTING ON)
endif()
if(BUILD_TESTING)
enable_testing()
add_subdirectory(tests)
......
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
set(header_files
clangmm.h
CodeCompleteResults.h
CompilationDatabase.h
CompileCommand.h
CompileCommands.h
CompletionString.h
Cursor.h
Index.h
SourceLocation.h
SourceRange.h
Token.h
Tokens.h
TranslationUnit.h
Diagnostic.h
Utility.h
)
set(cc_files
add_library(clangmm
CodeCompleteResults.cc
CompilationDatabase.cc
CompileCommand.cc
......@@ -32,12 +13,33 @@ set(cc_files
TranslationUnit.cc
Diagnostic.cc
Utility.cc
)
)
add_library(${project_name} SHARED ${header_files} ${cc_files})
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake_modules")
find_package(LibClang REQUIRED)
include_directories(${LIBCLANG_INCLUDE_DIRS})
target_link_libraries(${project_name} ${LIBCLANG_LIBRARIES})
target_link_libraries(clangmm ${LIBCLANG_LIBRARIES})
target_include_directories(clangmm PUBLIC ${LIBCLANG_INCLUDE_DIRS} .)
install(TARGETS ${project_name} RUNTIME DESTINATION bin LIBRARY DESTINATION lib)
install(FILES ${header_files} DESTINATION include/libclangmm)
if(${NOT_SUB_PROJECT})
install(TARGETS clangmm ARCHIVE DESTINATION lib)
install(FILES
clangmm.h
CodeCompleteResults.h
CompilationDatabase.h
CompileCommand.h
CompileCommands.h
CompletionString.h
Cursor.h
Index.h
SourceLocation.h
SourceRange.h
Token.h
Tokens.h
TranslationUnit.h
Diagnostic.h
Utility.h
DESTINATION include/libclangmm
)
endif()
set(project_tests ${project_name}_tests)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DLIBCLANGMM_TESTS_PATH=\\\"${CMAKE_CURRENT_SOURCE_DIR}\\\"")
include_directories(${LIBCLANG_INCLUDE_DIRS} "${PROJECT_SOURCE_DIR}/src")
add_definitions(-DLIBCLANGMM_TESTS_PATH="${CMAKE_CURRENT_SOURCE_DIR}")
add_executable(code_complete_results_test code_complete_results_test.cc)
target_link_libraries(code_complete_results_test ${LIBCLANG_LIBRARIES} clangmm)
target_link_libraries(code_complete_results_test clangmm)
add_test(code_complete_results_test code_complete_results_test)
add_executable(completion_string_test completion_string_test.cc)
target_link_libraries(completion_string_test ${LIBCLANG_LIBRARIES} clangmm)
target_link_libraries(completion_string_test clangmm)
add_test(completion_string_test completion_string_test)
add_executable(cursor_test cursor_test.cc)
target_link_libraries(cursor_test ${LIBCLANG_LIBRARIES} clangmm)
target_link_libraries(cursor_test clangmm)
add_test(cursor_test cursor_test)
add_executable(diagnostics_test diagnostics_test.cc)
target_link_libraries(diagnostics_test ${LIBCLANG_LIBRARIES} clangmm)
target_link_libraries(diagnostics_test clangmm)
add_test(diagnostics_test diagnostics_test)
add_executable(source_location_test source_location_test.cc)
target_link_libraries(source_location_test ${LIBCLANG_LIBRARIES} clangmm)
target_link_libraries(source_location_test clangmm)
add_test(source_location_test source_location_test)
add_executable(token_test token_test.cc)
target_link_libraries(token_test ${LIBCLANG_LIBRARIES} clangmm)
target_link_libraries(token_test clangmm)
add_test(token_test token_test)
add_executable(translation_unit_test translation_unit_test.cc)
target_link_libraries(translation_unit_test ${LIBCLANG_LIBRARIES} clangmm)
target_link_libraries(translation_unit_test clangmm)
add_test(translation_unit_test translation_unit_test)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment