Skip to content

Commit 053044a

Browse files
committed
Replace CMAKE_SOURCE_DIR/CMAKE_BINARY_DIR with PROJECT_SOURCE_DIR/PROJECT_BINARY_DIR
If OpenBLAS is built using add_subdirectory(OpenBlas) as part of another project then the paths set by CMAKE_XXX_DIR are relative to the parent project and not the OpenBLAS project.
1 parent bd06b24 commit 053044a

File tree

16 files changed

+41
-41
lines changed

16 files changed

+41
-41
lines changed

CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ endif()
4545

4646
message(WARNING "CMake support is experimental. This will not produce the same Makefiles that OpenBLAS ships with. Only x86 support is currently available.")
4747

48-
include("${CMAKE_SOURCE_DIR}/cmake/utils.cmake")
49-
include("${CMAKE_SOURCE_DIR}/cmake/system.cmake")
48+
include("${PROJECT_SOURCE_DIR}/cmake/utils.cmake")
49+
include("${PROJECT_SOURCE_DIR}/cmake/system.cmake")
5050

5151
set(BLASDIRS interface driver/level2 driver/level3 driver/others)
5252

@@ -123,9 +123,9 @@ endforeach ()
123123
# Can't just use lapack-netlib's CMake files, since they are set up to search for BLAS, build and install a binary. We just want to build a couple of lib files out of lapack and lapacke.
124124
# Not using add_subdirectory here because lapack-netlib already has its own CMakeLists.txt. Instead include a cmake script with the sources we want.
125125
if (NOT NOFORTRAN AND NOT NO_LAPACK)
126-
include("${CMAKE_SOURCE_DIR}/cmake/lapack.cmake")
126+
include("${PROJECT_SOURCE_DIR}/cmake/lapack.cmake")
127127
if (NOT NO_LAPACKE)
128-
include("${CMAKE_SOURCE_DIR}/cmake/lapacke.cmake")
128+
include("${PROJECT_SOURCE_DIR}/cmake/lapacke.cmake")
129129
endif ()
130130
endif ()
131131

@@ -137,7 +137,7 @@ endif()
137137
# add objects to the openblas lib
138138
add_library(${OpenBLAS_LIBNAME} SHARED ${LA_SOURCES} ${LAPACKE_SOURCES} ${TARGET_OBJS} ${OpenBLAS_DEF_FILE})
139139

140-
include("${CMAKE_SOURCE_DIR}/cmake/export.cmake")
140+
include("${PROJECT_SOURCE_DIR}/cmake/export.cmake")
141141

142142
# Set output for libopenblas
143143
set_target_properties( ${OpenBLAS_LIBNAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)

cmake/export.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ endif()
5353
add_custom_command(
5454
TARGET ${OpenBLAS_LIBNAME} PRE_LINK
5555
COMMAND perl
56-
ARGS "${CMAKE_SOURCE_DIR}/exports/gensymbol" "win2k" "${ARCH_IN}" "dummy" "${EXPRECISION_IN}" "${NO_CBLAS_IN}" "${NO_LAPACK_IN}" "${NO_LAPACKE_IN}" "${NEED2UNDERSCORES_IN}" "${ONLY_CBLAS_IN}" "${SYMBOLPREFIX}" "${SYMBOLSUFFIX}" > "${PROJECT_BINARY_DIR}/openblas.def"
56+
ARGS "${PROJECT_SOURCE_DIR}/exports/gensymbol" "win2k" "${ARCH_IN}" "dummy" "${EXPRECISION_IN}" "${NO_CBLAS_IN}" "${NO_LAPACK_IN}" "${NO_LAPACKE_IN}" "${NEED2UNDERSCORES_IN}" "${ONLY_CBLAS_IN}" "${SYMBOLPREFIX}" "${SYMBOLSUFFIX}" > "${PROJECT_BINARY_DIR}/openblas.def"
5757
COMMENT "Create openblas.def file"
5858
VERBATIM)
5959

cmake/prebuild.cmake

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,20 @@ else()
5050
set(TARGET_CONF "config.h")
5151
endif ()
5252

53-
include("${CMAKE_SOURCE_DIR}/cmake/c_check.cmake")
53+
include("${PROJECT_SOURCE_DIR}/cmake/c_check.cmake")
5454

5555
if (NOT NOFORTRAN)
56-
include("${CMAKE_SOURCE_DIR}/cmake/f_check.cmake")
56+
include("${PROJECT_SOURCE_DIR}/cmake/f_check.cmake")
5757
endif ()
5858

5959
# compile getarch
6060
set(GETARCH_SRC
61-
${CMAKE_SOURCE_DIR}/getarch.c
61+
${PROJECT_SOURCE_DIR}/getarch.c
6262
${CPUIDEMO}
6363
)
6464

6565
if (NOT MSVC)
66-
list(APPEND GETARCH_SRC ${CMAKE_SOURCE_DIR}/cpuid.S)
66+
list(APPEND GETARCH_SRC ${PROJECT_SOURCE_DIR}/cpuid.S)
6767
endif ()
6868

6969
if (MSVC)
@@ -76,7 +76,7 @@ set(GETARCH_BIN "getarch${CMAKE_EXECUTABLE_SUFFIX}")
7676
file(MAKE_DIRECTORY ${GETARCH_DIR})
7777
try_compile(GETARCH_RESULT ${GETARCH_DIR}
7878
SOURCES ${GETARCH_SRC}
79-
COMPILE_DEFINITIONS ${EXFLAGS} ${GETARCH_FLAGS} -I${CMAKE_SOURCE_DIR}
79+
COMPILE_DEFINITIONS ${EXFLAGS} ${GETARCH_FLAGS} -I${PROJECT_SOURCE_DIR}
8080
OUTPUT_VARIABLE GETARCH_LOG
8181
COPY_FILE ${PROJECT_BINARY_DIR}/${GETARCH_BIN}
8282
)
@@ -97,8 +97,8 @@ set(GETARCH2_DIR "${PROJECT_BINARY_DIR}/getarch2_build")
9797
set(GETARCH2_BIN "getarch_2nd${CMAKE_EXECUTABLE_SUFFIX}")
9898
file(MAKE_DIRECTORY ${GETARCH2_DIR})
9999
try_compile(GETARCH2_RESULT ${GETARCH2_DIR}
100-
SOURCES ${CMAKE_SOURCE_DIR}/getarch_2nd.c
101-
COMPILE_DEFINITIONS ${EXFLAGS} ${GETARCH_FLAGS} ${GETARCH2_FLAGS} -I${CMAKE_SOURCE_DIR}
100+
SOURCES ${PROJECT_SOURCE_DIR}/getarch_2nd.c
101+
COMPILE_DEFINITIONS ${EXFLAGS} ${GETARCH_FLAGS} ${GETARCH2_FLAGS} -I${PROJECT_SOURCE_DIR}
102102
OUTPUT_VARIABLE GETARCH2_LOG
103103
COPY_FILE ${PROJECT_BINARY_DIR}/${GETARCH2_BIN}
104104
)

cmake/system.cmake

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Description: Ported from OpenBLAS/Makefile.system
44
##
55

6-
set(NETLIB_LAPACK_DIR "${CMAKE_SOURCE_DIR}/lapack-netlib")
6+
set(NETLIB_LAPACK_DIR "${PROJECT_SOURCE_DIR}/lapack-netlib")
77

88
# TODO: Makefile.system detects Darwin (mac) and switches to clang here -hpa
99
# http://stackoverflow.com/questions/714100/os-detecting-makefile
@@ -78,7 +78,7 @@ else ()
7878
set(ONLY_CBLAS 0)
7979
endif ()
8080

81-
include("${CMAKE_SOURCE_DIR}/cmake/prebuild.cmake")
81+
include("${PROJECT_SOURCE_DIR}/cmake/prebuild.cmake")
8282

8383
if (NOT DEFINED NUM_THREADS)
8484
set(NUM_THREADS ${NUM_CORES})
@@ -124,17 +124,17 @@ set(OBJCOPY "${CROSS_SUFFIX}objcopy")
124124
set(OBJCONV "${CROSS_SUFFIX}objconv")
125125

126126
# OS dependent settings
127-
include("${CMAKE_SOURCE_DIR}/cmake/os.cmake")
127+
include("${PROJECT_SOURCE_DIR}/cmake/os.cmake")
128128

129129
# Architecture dependent settings
130-
include("${CMAKE_SOURCE_DIR}/cmake/arch.cmake")
130+
include("${PROJECT_SOURCE_DIR}/cmake/arch.cmake")
131131

132132
# C Compiler dependent settings
133-
include("${CMAKE_SOURCE_DIR}/cmake/cc.cmake")
133+
include("${PROJECT_SOURCE_DIR}/cmake/cc.cmake")
134134

135135
if (NOT NOFORTRAN)
136136
# Fortran Compiler dependent settings
137-
include("${CMAKE_SOURCE_DIR}/cmake/fc.cmake")
137+
include("${PROJECT_SOURCE_DIR}/cmake/fc.cmake")
138138
endif ()
139139

140140
if (BINARY64)
@@ -247,10 +247,10 @@ if (NOT DEFINED SYMBOLSUFFIX)
247247
set(SYMBOLSUFFIX "")
248248
endif ()
249249

250-
set(KERNELDIR "${CMAKE_SOURCE_DIR}/kernel/${ARCH}")
250+
set(KERNELDIR "${PROJECT_SOURCE_DIR}/kernel/${ARCH}")
251251

252252
# TODO: nead to convert these Makefiles
253-
# include ${CMAKE_SOURCE_DIR}/cmake/${ARCH}.cmake
253+
# include ${PROJECT_SOURCE_DIR}/cmake/${ARCH}.cmake
254254

255255
if (${CORE} STREQUAL "PPC440")
256256
set(CCOMMON_OPT "${CCOMMON_OPT} -DALLOC_QALLOC")
@@ -410,8 +410,8 @@ set(LIBDEFNAME "${LIBNAME}.${LIBSUFFIX}.def")
410410
set(LIBEXPNAME "${LIBNAME}.${LIBSUFFIX}.exp")
411411
set(LIBZIPNAME "${LIBNAME}.${LIBSUFFIX}.zip")
412412

413-
set(LIBS "${CMAKE_SOURCE_DIR}/${LIBNAME}")
414-
set(LIBS_P "${CMAKE_SOURCE_DIR}/${LIBNAME_P}")
413+
set(LIBS "${PROJECT_SOURCE_DIR}/${LIBNAME}")
414+
set(LIBS_P "${PROJECT_SOURCE_DIR}/${LIBNAME_P}")
415415

416416

417417
set(LIB_COMPONENTS BLAS)

ctest/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
include_directories(${CMAKE_SOURCE_DIR})
1+
include_directories(${PROJECT_SOURCE_DIR})
22

33
enable_language(Fortran)
44

driver/level2/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
include_directories(${CMAKE_SOURCE_DIR})
2+
include_directories(${PROJECT_SOURCE_DIR})
33

44
# sources that need to be compiled twice, once with no flags and once with LOWER
55
set(UL_SOURCES

driver/level3/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
include_directories(${CMAKE_SOURCE_DIR})
1+
include_directories(${PROJECT_SOURCE_DIR})
22

33
# N.B. In the original makefile there was a BLOCKS define used in the compilation of these files but I don't see any evidence of it being set anywhere. -hpa
44

driver/others/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
include_directories(${CMAKE_SOURCE_DIR})
1+
include_directories(${PROJECT_SOURCE_DIR})
22

33
if (${CORE} STREQUAL "PPC440")
44
set(MEMORY memory_qalloc.c)

interface/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
include_directories(${CMAKE_SOURCE_DIR})
2+
include_directories(${PROJECT_SOURCE_DIR})
33

44

55
set(BLAS1_SOURCES

kernel/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

2-
include_directories(${CMAKE_SOURCE_DIR})
3-
include("${CMAKE_SOURCE_DIR}/cmake/kernel.cmake")
2+
include_directories(${PROJECT_SOURCE_DIR})
3+
include("${PROJECT_SOURCE_DIR}/cmake/kernel.cmake")
44

55
# Makefile
66

0 commit comments

Comments
 (0)