Skip to content

Commit

Permalink
polserver can now be imported as subdirectory (#613)
Browse files Browse the repository at this point in the history
antlr/fmt build on linux with fPIC
clib publishes global config include dir and pol-core
  • Loading branch information
turleypol committed Jan 29, 2024
1 parent 686090d commit f8f2510
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 19 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.9)

#protect the user from himself
if(" ${CMAKE_SOURCE_DIR}" STREQUAL " ${CMAKE_BINARY_DIR}")
if(" ${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL " ${CMAKE_BINARY_DIR}")
message(FATAL_ERROR "
FATAL: In-source builds are not allowed.
Remove CMakeCache.txt and CMakeFiles folder and
Expand Down Expand Up @@ -74,8 +74,8 @@ include(TestBigEndian)

include(cmake/init.cmake)

set(POL_EXT_LIB_DIR "${CMAKE_SOURCE_DIR}/lib")
set(output_bin_dir "${CMAKE_SOURCE_DIR}/bin")
set(POL_EXT_LIB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lib")
set(output_bin_dir "${CMAKE_CURRENT_SOURCE_DIR}/bin")

message("####################################")
message("## ${PROJECT_NAME} - ${POL_VERSION_STR}")
Expand Down
11 changes: 10 additions & 1 deletion cmake/Antlr.cmake
Expand Up @@ -18,7 +18,16 @@ if (NOT EXISTS ${ANTLR_LIB})
SOURCE_DIR ${ANTLR_SOURCE_DIR}
PREFIX antlr
LIST_SEPARATOR |
CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${ANTLR_INSTALL_DIR} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DWITH_LIBCXX=Off -DANTLR_BUILD_SHARED=Off -DANTLR_BUILD_CPP_TESTS=Off -DCMAKE_OSX_ARCHITECTURES=${PIPED_OSX_ARCHITECTURES}
CMAKE_ARGS
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_INSTALL_PREFIX=${ANTLR_INSTALL_DIR}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DWITH_LIBCXX=Off
-DANTLR_BUILD_SHARED=Off
-DANTLR_BUILD_CPP_TESTS=Off
-DCMAKE_OSX_ARCHITECTURES=${PIPED_OSX_ARCHITECTURES}
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
BINARY_DIR ${ANTLR_SOURCE_DIR}/build
BUILD_COMMAND ${CMAKE_COMMAND} --build . --config Release
INSTALL_COMMAND ${CMAKE_COMMAND} --build . --config Release --target install
Expand Down
1 change: 1 addition & 0 deletions cmake/Fmt.cmake
Expand Up @@ -13,6 +13,7 @@ set(FMT_ARGS -DCMAKE_BUILD_TYPE=Release
-DCMAKE_USER_MAKE_RULES_OVERRIDE_C=${CMAKE_CURRENT_LIST_DIR}/c_flag_overrides.cmake
-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded # /Mt instead lf /Md
-DCMAKE_OSX_ARCHITECTURES=${PIPED_OSX_ARCHITECTURES}
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
)
if (${linux})
set(FMT_LIB "${FMT_INSTALL_DIR}/lib/libfmt.a")
Expand Down
9 changes: 0 additions & 9 deletions cmake/compile_defs.cmake
Expand Up @@ -2,16 +2,7 @@ function(set_compile_flags target is_executable)
message("* ${target}")
target_include_directories(${target} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR} #own folder
${PROJECT_BINARY_DIR} #global config
)

# Add 'pol-core' to the include search path of all the projects in it
if (${INCLUDE_POLCORE_DIR})
target_include_directories(${target} PRIVATE
${POLCORE_DIR} # path to pol-core
)
endif()

target_compile_definitions(${target} PRIVATE
INC_PASSERT=1
__STDC_CONSTANT_MACROS
Expand Down
5 changes: 0 additions & 5 deletions pol-core/CMakeLists.txt
Expand Up @@ -27,9 +27,6 @@ endif()

set(POLCORE_DIR ${CMAKE_CURRENT_LIST_DIR})

# For the next targets, add pol-core to the include search path (done in set_compiler_flags)
set(INCLUDE_POLCORE_DIR 1)

add_subdirectory(clib)
add_subdirectory(bscript)
add_subdirectory(plib)
Expand All @@ -53,8 +50,6 @@ if (BUILD_ALL OR ONLY_POLTOOL)
add_subdirectory(poltool)
endif()

unset(INCLUDE_POLCORE_DIR)

add_subdirectory(doc)
add_subdirectory(support)

8 changes: 7 additions & 1 deletion pol-core/clib/CMakeLists.txt
Expand Up @@ -23,11 +23,17 @@ target_link_libraries(${lib_name} PUBLIC
# libboost_thread
)

#since clib is our baselib make here the include dirs public
target_include_directories(${lib_name} PUBLIC
${POLCORE_DIR} # path to pol-core
${PROJECT_BINARY_DIR} #global config
)

if (${linux})
if (APPLE)
pkg_search_module(OPENSSL QUIET openssl)
target_include_directories(${lib_name} PRIVATE ${OPENSSL_INCLUDEDIR})
target_link_directories(${lib_name} PRIVATE ${OPENSSL_LIBDIR})
target_link_directories(${lib_name} PUBLIC ${OPENSSL_LIBDIR})
endif()
target_link_libraries(${lib_name} PRIVATE
crypto
Expand Down

0 comments on commit f8f2510

Please sign in to comment.