Skip to content

Commit

Permalink
CMake: libraries in the same dir on all platforms
Browse files Browse the repository at this point in the history
Now the libraries are created in the same directories on all platforms. Also on
Windows the Release/Debug subdirectory is not added to the path.
  • Loading branch information
certik committed Feb 22, 2022
1 parent bf6a743 commit ddfd564
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ci/build.xsh
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jupyter kernelspec list --json

cp lpython-$lpython_version/test-bld/src/bin/lpython src/bin
if $WIN == "1":
cp lpython-$lpython_version/test-bld/src/runtime/legacy/lfortran_runtime* src/runtime/
cp lpython-$lpython_version/test-bld/src/runtime/lfortran_runtime* src/runtime/
else:
cp lpython-$lpython_version/test-bld/src/runtime/liblfortran_runtime* src/runtime/
cp lpython-$lpython_version/test-bld/src/runtime/*.mod src/runtime/
Expand Down
5 changes: 5 additions & 0 deletions src/bin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,8 @@ install(TARGETS lpython
ARCHIVE DESTINATION share/lpython/lib
LIBRARY DESTINATION share/lpython/lib
)

set_target_properties(lpython PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/$<0:>
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/$<0:>
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/$<0:>)
5 changes: 5 additions & 0 deletions src/lpython/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ add_executable(test_lfortran ${SRC})
target_link_libraries(test_lfortran lfortran_lib p::doctest)
add_test(test_lfortran ${PROJECT_BINARY_DIR}/test_lfortran)

set_target_properties(test_lfortran PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/$<0:>
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/$<0:>
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/$<0:>)

if (WITH_LLVM)
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_link_options(test_lfortran PRIVATE "LINKER:--export-dynamic")
Expand Down
8 changes: 6 additions & 2 deletions src/runtime/legacy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ set(SRC
)
add_library(lfortran_runtime SHARED ${SRC})
set_target_properties(lfortran_runtime PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ..)
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../$<0:>
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../$<0:>
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../$<0:>)
add_library(lfortran_runtime_static STATIC ${SRC})
set_target_properties(lfortran_runtime_static PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ..)
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../$<0:>
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../$<0:>
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../$<0:>)
install(TARGETS lfortran_runtime lfortran_runtime_static
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
ARCHIVE DESTINATION share/lpython/lib
Expand Down

0 comments on commit ddfd564

Please sign in to comment.