Skip to content

Commit

Permalink
Adjust cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
beckdave committed May 22, 2023
1 parent 5193a6e commit 0c1ffc6
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 37 deletions.
24 changes: 17 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ else()
endif()


SET(FINALMQ_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
SET(FINALMQ_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})


include(FetchContent)

function(CloneRepository repositoryURL branchName projectName sourceDir)
Expand All @@ -34,7 +38,7 @@ function(CloneRepository repositoryURL branchName projectName sourceDir)
FetchContent_MakeAvailable(${projectName})
endfunction(CloneRepository)

CloneRepository("https://github.com/beckdave/hl7-dictionary.git" "beckdave-fix-compounds" "hl7-dictionary" "${CMAKE_BINARY_DIR}/hl7-dictionary")
CloneRepository("https://github.com/beckdave/hl7-dictionary.git" "beckdave-fix-compounds" "hl7-dictionary" "${FINALMQ_BINARY_DIR}/hl7-dictionary")

# Add compile flags to determine coverage
if (FINALMQ_BUILD_COVERAGE)
Expand Down Expand Up @@ -91,7 +95,7 @@ else( IS_ABSOLUTE ${GCOVR} )
endif( IS_ABSOLUTE ${GCOVR} )
endif(FINALMQ_BUILD_COVERAGE)

SET(CODEGENERATOR ${CMAKE_SOURCE_DIR}/codegenerator)
SET(CODEGENERATOR ${FINALMQ_SOURCE_DIR}/codegenerator)


include_directories(${CMAKE_CURRENT_BINARY_DIR}/inc)
Expand Down Expand Up @@ -140,7 +144,7 @@ add_custom_command(


#Bring the headers into the project
include_directories(inc)
#include_directories(inc)

#However, the file(GLOB...) allows for wildcard additions:
file(GLOB SOURCES "src/*.cpp" "inc/finalmq/*.h"
Expand Down Expand Up @@ -168,16 +172,20 @@ file(GLOB SOURCES "src/*.cpp" "inc/finalmq/*.h"
"inc/finalmq/conversions/*.h"
"mock/*.h")

#Generate the shared library from the sources
add_library(finalmq SHARED ${SOURCES}
#Generate the library from the sources

SET(FINALMQ_LIBRARY_SOURCES ${SOURCES}
${CMAKE_CURRENT_BINARY_DIR}/inc/finalmq/metadataserialize/metadata.fmq.cpp
${CMAKE_CURRENT_BINARY_DIR}/inc/finalmq/metadataserialize/variant.fmq.cpp
${CMAKE_CURRENT_BINARY_DIR}/inc/finalmq/remoteentity/entitydata.fmq.cpp
${CMAKE_CURRENT_BINARY_DIR}/inc/finalmq/interfaces/fmqreg.fmq.cpp
${CMAKE_CURRENT_BINARY_DIR}/inc/finalmq/Qt/qtdata.fmq.cpp
)
${CMAKE_CURRENT_BINARY_DIR}/inc/finalmq/Qt/qtdata.fmq.cpp)

add_library(finalmq SHARED ${FINALMQ_LIBRARY_SOURCES})
add_library(finalmqStatic STATIC ${FINALMQ_LIBRARY_SOURCES})

target_include_directories(finalmq PUBLIC ${FINALMQ_SOURCE_DIR}/inc)
target_include_directories(finalmqStatic PUBLIC ${FINALMQ_SOURCE_DIR}/inc)

if (WIN32)
message("== WIN32 ==")
Expand All @@ -189,9 +197,11 @@ if (WIN32)
set(LINKLIBS ${LINKLIBS} wsock32 ws2_32 Rpcrt4 "${OPENSSL_DIR}/lib/libssl.lib" "${OPENSSL_DIR}/lib/libcrypto.lib")
endif()
target_compile_options(finalmq PRIVATE -DEXPORT_finalmq)
target_compile_options(finalmqStatic PRIVATE -DEXPORT_finalmq)
elseif(UNIX)
message("== UNIX ==")
target_compile_options(finalmq PRIVATE -Werror -Wall -Wextra)
target_compile_options(finalmqStatic PRIVATE -Werror -Wall -Wextra)
if (${CMAKE_SYSTEM_NAME} MATCHES "QNX")
message("== QNX ==")
else()
Expand Down
4 changes: 2 additions & 2 deletions examples/cpp/experimental/http/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ set(CMAKE_CXX_STANDARD 14)


#include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_SOURCE_DIR}/inc)
include_directories(${FINALMQ_SOURCE_DIR}/inc)


if (WIN32)
link_directories(${OPENSSL_DIR}/lib ${CMAKE_BINARY_DIR})
link_directories(${OPENSSL_DIR}/lib ${FINALMQ_BINARY_DIR})
endif()


Expand Down
6 changes: 3 additions & 3 deletions examples/cpp/experimental/registry/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ set(CMAKE_CXX_STANDARD 14)



SET(CODEGENERATOR ${CMAKE_SOURCE_DIR}/codegenerator)
SET(CODEGENERATOR ${FINALMQ_SOURCE_DIR}/codegenerator)



Expand All @@ -37,11 +37,11 @@ add_custom_command(


include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_SOURCE_DIR}/inc)
include_directories(${FINALMQ_SOURCE_DIR}/inc)


if (WIN32)
link_directories(${OPENSSL_DIR}/lib ${CMAKE_BINARY_DIR})
link_directories(${OPENSSL_DIR}/lib ${FINALMQ_BINARY_DIR})
endif()


Expand Down
8 changes: 4 additions & 4 deletions examples/cpp/helloworld/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.10)

project(helloworld)

file(COPY ${CMAKE_SOURCE_DIR}/htdocs DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
file(COPY ${FINALMQ_SOURCE_DIR}/htdocs DESTINATION ${CMAKE_CURRENT_BINARY_DIR})


if (FINALMQ_USE_SSL)
Expand All @@ -21,7 +21,7 @@ set(CMAKE_CXX_STANDARD 14)



SET(CODEGENERATOR ${CMAKE_SOURCE_DIR}/codegenerator)
SET(CODEGENERATOR ${FINALMQ_SOURCE_DIR}/codegenerator)



Expand All @@ -39,11 +39,11 @@ add_custom_command(


include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_SOURCE_DIR}/inc)
include_directories(${FINALMQ_SOURCE_DIR}/inc)


if (WIN32)
link_directories(${OPENSSL_DIR}/lib ${CMAKE_BINARY_DIR})
link_directories(${OPENSSL_DIR}/lib ${FINALMQ_BINARY_DIR})
endif()


Expand Down
14 changes: 7 additions & 7 deletions examples/cpp/hl7/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ cmake_minimum_required(VERSION 3.10)

project(hl7)

file(COPY ${CMAKE_SOURCE_DIR}/htdocs DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
file(COPY ${CMAKE_SOURCE_DIR}/htdocs DESTINATION ${CMAKE_BINARY_DIR})
file(COPY ${FINALMQ_SOURCE_DIR}/htdocs DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
file(COPY ${FINALMQ_SOURCE_DIR}/htdocs DESTINATION ${FINALMQ_BINARY_DIR})


if (FINALMQ_USE_SSL)
Expand All @@ -22,7 +22,7 @@ set(CMAKE_CXX_STANDARD 14)



SET(CODEGENERATOR ${CMAKE_SOURCE_DIR}/codegenerator)
SET(CODEGENERATOR ${FINALMQ_SOURCE_DIR}/codegenerator)


set(CODEGENERATOR_HL7DEF ${CODEGENERATOR}/hl7/hl7.js)
Expand All @@ -34,8 +34,8 @@ set(CODEGENERATOR_CPP ${CODEGENERATOR}/cpp/cpp.js)
# In hl7options.json there is a filter to use only the messages (trigger events) you need in
# your project.

set(HL7DEF_DICTIONARY ${CMAKE_BINARY_DIR}/hl7-dictionary/dist/hl7dictionary.2.7.1.js)
set(HL7DEF_TABLES ${CMAKE_BINARY_DIR}/hl7-dictionary/lib/tables.js)
set(HL7DEF_DICTIONARY ${FINALMQ_BINARY_DIR}/hl7-dictionary/dist/hl7dictionary.2.7.1.js)
set(HL7DEF_TABLES ${FINALMQ_BINARY_DIR}/hl7-dictionary/lib/tables.js)
set(HL7DEF_FMQ ${CMAKE_CURRENT_BINARY_DIR}/hl7dictionary.2.7.1.js.fmq)
set(HL7DEF_OPTIONS ${CMAKE_CURRENT_SOURCE_DIR}/hl7options.json)
add_custom_command(
Expand All @@ -58,11 +58,11 @@ add_custom_command(


include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_SOURCE_DIR}/inc)
include_directories(${FINALMQ_SOURCE_DIR}/inc)


if (WIN32)
link_directories(${OPENSSL_DIR}/lib ${CMAKE_BINARY_DIR})
link_directories(${OPENSSL_DIR}/lib ${FINALMQ_BINARY_DIR})
endif()


Expand Down
8 changes: 4 additions & 4 deletions examples/cpp/restapi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.10)

project(restapi)

file(COPY ${CMAKE_SOURCE_DIR}/htdocs DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
file(COPY ${FINALMQ_SOURCE_DIR}/htdocs DESTINATION ${CMAKE_CURRENT_BINARY_DIR})


if (FINALMQ_USE_SSL)
Expand All @@ -21,7 +21,7 @@ set(CMAKE_CXX_STANDARD 14)



SET(CODEGENERATOR ${CMAKE_SOURCE_DIR}/codegenerator)
SET(CODEGENERATOR ${FINALMQ_SOURCE_DIR}/codegenerator)



Expand All @@ -39,11 +39,11 @@ add_custom_command(


include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_SOURCE_DIR}/inc)
include_directories(${FINALMQ_SOURCE_DIR}/inc)


if (WIN32)
link_directories(${OPENSSL_DIR}/lib ${CMAKE_BINARY_DIR})
link_directories(${OPENSSL_DIR}/lib ${FINALMQ_BINARY_DIR})
endif()


Expand Down
8 changes: 4 additions & 4 deletions examples/cpp/timer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.10)
project(timer)


file(COPY ${CMAKE_SOURCE_DIR}/htdocs DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
file(COPY ${FINALMQ_SOURCE_DIR}/htdocs DESTINATION ${CMAKE_CURRENT_BINARY_DIR})



Expand All @@ -23,7 +23,7 @@ set(CMAKE_CXX_STANDARD 14)



SET(CODEGENERATOR ${CMAKE_SOURCE_DIR}/codegenerator)
SET(CODEGENERATOR ${FINALMQ_SOURCE_DIR}/codegenerator)



Expand All @@ -41,11 +41,11 @@ add_custom_command(


include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_SOURCE_DIR}/inc)
include_directories(${FINALMQ_SOURCE_DIR}/inc)


if (WIN32)
link_directories(${OPENSSL_DIR}/lib ${CMAKE_BINARY_DIR})
link_directories(${OPENSSL_DIR}/lib ${FINALMQ_BINARY_DIR})
endif()


Expand Down
12 changes: 6 additions & 6 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ cmake_minimum_required(VERSION 3.10)

file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/ssltest.cert.pem DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/ssltest.key.pem DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/ssltest.cert.pem DESTINATION ${CMAKE_BINARY_DIR})
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/ssltest.key.pem DESTINATION ${CMAKE_BINARY_DIR})
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/ssltest.cert.pem DESTINATION ${FINALMQ_BINARY_DIR})
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/ssltest.key.pem DESTINATION ${FINALMQ_BINARY_DIR})

# Prevent overriding the parent project's compiler/linker
# settings on Windows
Expand Down Expand Up @@ -75,8 +75,8 @@ add_custom_command(
)

add_custom_command(
COMMAND node ${CODEGENERATOR_PROTO} --input=${CMAKE_SOURCE_DIR}/inc/finalmq/metadataserialize/variant.fmq --outpath=${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${CMAKE_SOURCE_DIR}/inc/finalmq/metadataserialize/variant.fmq
COMMAND node ${CODEGENERATOR_PROTO} --input=${FINALMQ_SOURCE_DIR}/inc/finalmq/metadataserialize/variant.fmq --outpath=${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${FINALMQ_SOURCE_DIR}/inc/finalmq/metadataserialize/variant.fmq
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/variant.proto
COMMENT "Generating proto code out of variant.fmq."
)
Expand All @@ -94,9 +94,9 @@ PROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDRS ${CMAKE_CURRENT_BINARY_DIR}/variant.
message("proto headers: ${PROTO_HDRS}")

include_directories("${gmock_SOURCE_DIR}/include")
include_directories("${CMAKE_BINARY_DIR}/test")
include_directories("${FINALMQ_BINARY_DIR}/test")

include_directories("${CMAKE_SOURCE_DIR}/mock")
include_directories("${FINALMQ_SOURCE_DIR}/mock")

file(GLOB TESTSOURCES "*.cpp")
#file(GLOB GENCODE ${CMAKE_CURRENT_BINARY_DIR}/test.fmq.cpp ${CMAKE_CURRENT_BINARY_DIR}/hl7.fmq.cpp)
Expand Down

0 comments on commit 0c1ffc6

Please sign in to comment.