Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow cmake to build as both a standalone project as well as a subproject (ie add_subdirectory(mkl-dnn)) #44

Merged
merged 3 commits into from
Apr 13, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,22 @@
#===============================================================================

set(TARGET_NAME ${LIB_NAME})

file(GLOB_RECURSE HEADERS
${CMAKE_SOURCE_DIR}/include/*.h
${CMAKE_SOURCE_DIR}/include/*.hpp
${CMAKE_CURRENT_SOURCE_DIR}/../include/*.h
${CMAKE_CURRENT_SOURCE_DIR}/../include/*.hpp
)
file(GLOB_RECURSE SOURCES
${CMAKE_SOURCE_DIR}/src/*.c
${CMAKE_SOURCE_DIR}/src/*.cpp
${CMAKE_SOURCE_DIR}/src/*.h
${CMAKE_SOURCE_DIR}/src/*.hpp
${CMAKE_CURRENT_SOURCE_DIR}/*.c
${CMAKE_CURRENT_SOURCE_DIR}/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/*.h
${CMAKE_CURRENT_SOURCE_DIR}/*.hpp
)
include_directories(
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/src/common
${CMAKE_SOURCE_DIR}/src/cpu/xbyak
${CMAKE_CURRENT_SOURCE_DIR}/..
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any specific reason for adding this line?
${CMAKE_CURRENT_SOURCE_DIR}/..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/common
${CMAKE_CURRENT_SOURCE_DIR}/cpu/xbyak
)
add_library(${TARGET_NAME} SHARED ${HEADERS} ${SOURCES})
target_link_libraries(${TARGET_NAME} ${${TARGET_NAME}_LINKER_LIBS})
Expand Down
4 changes: 1 addition & 3 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ if(POLICY CMP0065)
cmake_policy(SET CMP0065 NEW)
endif()

include_directories(${CMAKE_SOURCE_DIR}/include)

#add_executable(api-check-c api_check.c)
#target_link_libraries(api-check-c ${LIB_NAME})
#add_test(api-check-c api-check-c)
Expand All @@ -39,7 +37,7 @@ add_executable(test_c_symbols-c ${test_c_symbols})
add_custom_command(
OUTPUT ${test_c_symbols}
COMMAND /bin/bash ${CMAKE_CURRENT_SOURCE_DIR}/generate_c_symbols_refs.sh
${CMAKE_SOURCE_DIR} ${test_c_symbols}
${CMAKE_CURRENT_SOURCE_DIR}/.. ${test_c_symbols}
)
target_link_libraries(test_c_symbols-c ${LIB_NAME})

Expand Down
10 changes: 5 additions & 5 deletions tests/gtests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ add_subdirectory (gtest)

set(APP_NAME "gtest")
set(MAIN_SRC_GTEST main.cpp)
include_directories(${CMAKE_SOURCE_DIR}/include)
include_directories(${CMAKE_SOURCE_DIR}/tests/gtests
${CMAKE_SOURCE_DIR}/tests/gtests/gtest

include_directories(${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/gtest
${CMAKE_CURRENT_SOURCE_DIR}/in
)
include_directories(${CMAKE_SOURCE_DIR}/tests/gtests/in)
# TODO: enable me!
#file(GLOB API_TEST_CASES_SRC api_tests/*.cpp)
#file(GLOB PRIM_TEST_CASES_SRC test_*.cpp)
file(GLOB PRIM_TEST_CASES_SRC RELATIVE ${CMAKE_SOURCE_DIR}/tests/gtests
file(GLOB PRIM_TEST_CASES_SRC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/../gtests
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is incompatible with cmake 2.8.11.

For some reasons PRIM_TEST_CASES_SRC = ../../test_sum.cpp;../../test_reorder.cpp;... rather than PRIM_TEST_CASES_SRC = test_sum.cpp;test_reorder.cpp;....

Is there any particular reason why you do this trick: ../gtests, even though you are already in this directory?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me check. I found the multiple gtest directories a little confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, removed

test_sum.cpp
test_reorder.cpp
test_concat.cpp
Expand Down
5 changes: 3 additions & 2 deletions tests/gtests/gtest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
set(TARGET_NAME gtest)
set(MAIN_SRC "src/gtest-all.cc")
source_group("" FILES ${MAIN_SRC})
include_directories(${CMAKE_SOURCE_DIR}/tests/gtests
${CMAKE_SOURCE_DIR}/tests/gtests/gtest)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/..
${CMAKE_CURRENT_SOURCE_DIR}/gtest)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same as here: what this line stands for?
${CMAKE_CURRENT_SOURCE_DIR}/gtest

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

find_package(Threads REQUIRED)
add_library(${TARGET_NAME} STATIC ${MAIN_SRC})
target_link_libraries(${TARGET_NAME} ${CMAKE_THREAD_LIBS_INIT})