Skip to content

Commit 612f092

Browse files
Bjoealeks-f
authored andcommitted
Cleanup cmake build system to use transitive dependency management from cmake (pocoproject#2321)
* Some cleanup in the root CMakeLists.txt * Cleanup cmake targets * Add find openssl modul for older cmake version * Set proper scope * Change crypto default to off * Fix openssl default to on * Remove global setting of C99 standard * Set from C11 to C99 * Fix for NetSSL win build * Set C99 compile features * Fix Windows build * Fix windows build * Cleanup poco unbundle definition * Fix PDF build * Remove unused set affinity * Add _CRT_SECURE_NO_WARNINGS as target compile definitions * Add _AFXDLL as target compile definitions * Remove commented out line * Refactor add_definitions to target_compile_definitons in Util * Refactor add_definitions to target_compile_definitons in XML * Remove THREADSAFE in data sql cmake build * Refactor add_definitions to target_compile_definition in cmake mysql * Refactor add_definitions to target_compile_definition in cmake odbc * Refactor add_definitions to target_compile_definition in cmake sqlite * Refactor add_definitions to target_compile_definitions in platform specific cmake * Add _DEBUG as compile definition * Add build dependencies between Foundation-testrunner and TestApp, TestLibrary in cmake build * Use cmake property to build shared libs * Cleanup POCO_NO_AUTOMATIC_LIBS. Set only for Windows in cmake build system * cleanup LIB_MODE_DEFINITIONS in cmake buld system * Add POCO_STATIC for CppUnit * Cleanup target link libraries and add option dependencies. * Add dependencies management in cmake * Update cmake documentation * Squashed commit of the following: commit 38c233f Fix "invalid new-expression of abstract class type ApacheServerRequest" (pocoproject#2231) - abstract method "bool secure() const" defined in HTTPServerRequest was implemented in ApacheServerRequest, one of its derived classes - a ap_log_error had one of its parameters changed for fixing a warning "passing NULL to non-pointer argument" - minor indentation problems corrected commit 4cbdfbe Fix build dependencies * Improve database cmake build dependencies * Update doc * Update doc * Update cmake build commands * Set public on target link libraries in cmake build system * Fix PostgreSQL build * Fix PostgreSQL build in cmake * Fix PostgreSQL from SQL to Data * Squashed commit of the following: commit 1ba7d5d Add missing cmake file * Set path to PostgresSQL in AppVoyer * Try to fix AppVeyor build * show dir in appvoyer * Disable PostgreSQL build on Appvoyer * Refactor add_definitions to target_compile_definitions
1 parent 4542a15 commit 612f092

File tree

128 files changed

+1685
-1349
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+1685
-1349
lines changed

.travis.yml

+8-8
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ before_install:
1010
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then tar -xzvf cmake-3.2.3-Linux-x86_64.tar.gz; fi
1111
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then export PATH=$PWD/cmake-3.2.3-Linux-x86_64/bin:$PATH; fi
1212
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get update -qq; fi
13-
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install -qq -y unixodbc-dev libmysqlclient-dev g++-arm-linux-gnueabi g++-arm-linux-gnueabihf clang-3.5 libc++-dev sloccount cppcheck; fi
13+
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install -qq -y unixodbc-dev libmysqlclient-dev g++-arm-linux-gnueabi g++-arm-linux-gnueabihf clang-3.5 libc++-dev ninja-build sloccount cppcheck; fi
1414

1515
services:
1616
- mongodb
@@ -81,7 +81,7 @@ matrix:
8181
# See also in /usr/local/android-sdk/ndk-bundle/build/cmake/android.toolchain.cmake
8282

8383
# Using the ninja build command. Is much faster then make build command.
84-
- mkdir cmake-build && cd cmake-build && /usr/local/android-sdk/cmake/3.6.4111459/bin/cmake -G'Android Gradle - Ninja' -DANDROID_ABI=armeabi-v7a -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=/usr/local/android-sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-19 -DCMAKE_MAKE_PROGRAM=/usr/local/android-sdk/cmake/3.6.4111459/bin/ninja -DANDROID_STL="c++_static" -DANDROID_CPP_FEATURES="exceptions rtti" -DENABLE_TESTS=ON -DENABLE_LONG_RUNNING_TESTS=OFF -DOLD_REDIS_VERSION=ON .. && /usr/local/android-sdk/cmake/3.6.4111459/bin/cmake --build . --target all && travis_wait 30 /usr/local/android-sdk/cmake/3.6.4111459/bin/ctest -E Foundation --output-on-failure
84+
- /usr/local/android-sdk/cmake/3.6.4111459/bin/cmake -H. -Bcmake-build -G'Android Gradle - Ninja' -DANDROID_ABI=armeabi-v7a -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=/usr/local/android-sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-19 -DCMAKE_MAKE_PROGRAM=/usr/local/android-sdk/cmake/3.6.4111459/bin/ninja -DANDROID_STL="c++_static" -DANDROID_CPP_FEATURES="exceptions rtti" -DENABLE_TESTS=ON -DENABLE_LONG_RUNNING_TESTS=OFF -DOLD_REDIS_VERSION=ON && /usr/local/android-sdk/cmake/3.6.4111459/bin/cmake --build cmake-build --target all && cd cmake-build && travis_wait 30 /usr/local/android-sdk/cmake/3.6.4111459/bin/ctest -E Foundation --output-on-failure
8585

8686
- env: TEST_NAME="android API level 24"
8787
language: android
@@ -128,7 +128,7 @@ matrix:
128128
# See also in /usr/local/android-sdk/ndk-bundle/build/cmake/android.toolchain.cmake
129129

130130
# Using the ninja build command. Is much faster then make build command.
131-
- mkdir cmake-build && cd cmake-build && /usr/local/android-sdk/cmake/3.6.4111459/bin/cmake -G'Android Gradle - Ninja' -DANDROID_ABI=armeabi-v7a -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=/usr/local/android-sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-24 -DCMAKE_MAKE_PROGRAM=/usr/local/android-sdk/cmake/3.6.4111459/bin/ninja -DANDROID_STL="c++_static" -DANDROID_CPP_FEATURES="exceptions rtti" -DENABLE_TESTS=ON -DENABLE_LONG_RUNNING_TESTS=OFF -DOLD_REDIS_VERSION=ON .. && /usr/local/android-sdk/cmake/3.6.4111459/bin/cmake --build . --target all && travis_wait 30 /usr/local/android-sdk/cmake/3.6.4111459/bin/ctest -E Foundation --output-on-failure
131+
- /usr/local/android-sdk/cmake/3.6.4111459/bin/cmake -H. -Bcmake-build -G'Android Gradle - Ninja' -DANDROID_ABI=armeabi-v7a -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=/usr/local/android-sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-24 -DCMAKE_MAKE_PROGRAM=/usr/local/android-sdk/cmake/3.6.4111459/bin/ninja -DANDROID_STL="c++_static" -DANDROID_CPP_FEATURES="exceptions rtti" -DENABLE_TESTS=ON -DENABLE_LONG_RUNNING_TESTS=OFF -DOLD_REDIS_VERSION=ON && /usr/local/android-sdk/cmake/3.6.4111459/bin/cmake --build cmake-build --target all && cd cmake-build && travis_wait 30 /usr/local/android-sdk/cmake/3.6.4111459/bin/ctest -E Foundation --output-on-failure
132132

133133
- env: TEST_NAME="gcc (make)"
134134
compiler: gcc
@@ -150,7 +150,7 @@ matrix:
150150
compiler: gcc
151151
script:
152152
# disable tests, gcc-4.6 gets an internal compiler error
153-
- mkdir cmake-build && cd cmake-build && cmake -DENABLE_PDF=OFF -DENABLE_TESTS=OFF .. && make all -j2 && cd ..
153+
- cmake -H. -Bcmake-build -GNinja -DENABLE_PDF=OFF -DENABLE_TESTS=OFF && cmake --build cmake-build --target all
154154

155155
- env: TEST_NAME="gcc-4.8 (CMake)"
156156
compiler: gcc
@@ -160,24 +160,24 @@ matrix:
160160
- sudo apt-get install -qq -y g++-4.8
161161
- export CC="gcc-4.8"
162162
- export CXX="g++-4.8"
163-
- mkdir cmake-build && cd cmake-build && cmake -DENABLE_PDF=OFF -DENABLE_TESTS=ON .. && make all -j2 && cd ..
163+
- cmake -H. -Bcmake-build -GNinja -DENABLE_PDF=OFF -DENABLE_TESTS=ON && cmake --build cmake-build --target all
164164

165165
- env: TEST_NAME="clang (CMake)"
166166
compiler: clang
167167
script:
168-
- mkdir cmake-build && cd cmake-build && cmake -DENABLE_PDF=OFF -DENABLE_TESTS=ON .. && make all -j2 && cd ..
168+
- cmake -H. -Bcmake-build -GNinja -DENABLE_PDF=OFF -DENABLE_TESTS=ON && cmake --build cmake-build --target all
169169

170170
- env: TEST_NAME="arm-linux-gnueabi-g++ (CMake)"
171171
script:
172172
- export CC="arm-linux-gnueabi-gcc"
173173
- export CXX="arm-linux-gnueabi-g++"
174-
- mkdir cmake-build && cd cmake-build && cmake -DENABLE_PDF=OFF -DENABLE_NETSSL=OFF -DENABLE_CRYPTO=OFF -DENABLE_TESTS=ON .. && make all -j2 && cd ..
174+
- cmake -H. -Bcmake-build -GNinja -DENABLE_PDF=OFF -DENABLE_NETSSL=OFF -DENABLE_CRYPTO=OFF -DENABLE_TESTS=ON && cmake --build cmake-build --target all
175175

176176
- env: TEST_NAME="arm-linux-gnueabihf-g++ (CMake)"
177177
script:
178178
- export CC="arm-linux-gnueabihf-gcc"
179179
- export CXX="arm-linux-gnueabihf-g++"
180-
- mkdir cmake-build && cd cmake-build && cmake -DENABLE_PDF=OFF -DENABLE_NETSSL=OFF -DENABLE_CRYPTO=OFF -DENABLE_TESTS=ON .. && make all -j2 && cd ..
180+
- cmake -H. -Bcmake-build -GNinja -DENABLE_PDF=OFF -DENABLE_NETSSL=OFF -DENABLE_CRYPTO=OFF -DENABLE_TESTS=ON && cmake --build cmake-build --target all
181181

182182
# TODO osx build
183183
# TODO run test suite

ApacheConnector/CMakeLists.txt

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
set(LIBNAME "mod_poco")
2-
31
# Sources
42
file(GLOB SRCS_G "src/*.cpp")
53
POCO_SOURCES_AUTO( SRCS ${SRCS_G})
@@ -8,19 +6,19 @@ POCO_SOURCES_AUTO( SRCS ${SRCS_G})
86
file(GLOB_RECURSE HDRS_G "include/*.h" )
97
POCO_HEADERS_AUTO( SRCS ${HDRS_G})
108

11-
add_library( "${LIBNAME}" SHARED ${SRCS} )
12-
set_target_properties( "${LIBNAME}"
9+
add_library(mod_poco SHARED ${SRCS})
10+
set_target_properties(mod_poco
1311
PROPERTIES
1412
VERSION ${SHARED_LIBRARY_VERSION} SOVERSION ${SHARED_LIBRARY_VERSION}
1513
DEFINE_SYMBOL ApacheHandlers_EXPORTS)
16-
target_link_libraries( "${LIBNAME}" )
17-
target_include_directories( "${LIBNAME}"
14+
target_include_directories(mod_poco
1815
PUBLIC
1916
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
2017
$<INSTALL_INTERFACE:include>
2118
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src
2219
)
20+
target_link_libraries(mod_poco PUBLIC Poco::Util Poco::Net)
2321

2422
if (ENABLE_TESTS)
2523
add_subdirectory(samples)
26-
endif ()
24+
endif ()

ApacheConnector/include/ApacheConnector.h

+8-2
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,20 @@ class ApacheRequestRec
4848

4949
void sendErrorResponse(int status);
5050
/// Sends an error response with the given HTTP status code.
51-
51+
5252
int sendFile(const std::string& path, unsigned int fileSize, const std::string& mediaType);
5353
/// Sends the file given by fileName as response.
5454

5555
void copyHeaders(ApacheServerRequest& request);
5656
/// Copies the request uri and header fields from the Apache request
5757
/// to the ApacheServerRequest.
58-
58+
59+
bool secure();
60+
/// Returns true if the request is using a secure
61+
/// connection. Returns false if no secure connection
62+
/// is used, or if it is not known whether a secure
63+
/// connection is used.
64+
5965
private:
6066
request_rec* _pRec;
6167
};

ApacheConnector/include/ApacheServerRequest.h

+6
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ class ApacheServerRequest: public Poco::Net::HTTPServerRequest
5858
Poco::Net::HTTPServerResponse& response() const;
5959
/// Returns a reference to the associated response
6060

61+
bool secure() const;
62+
/// Returns true if the request is using a secure
63+
/// connection. Returns false if no secure connection
64+
/// is used, or if it is not known whether a secure
65+
/// connection is used.
66+
6167
protected:
6268
void setResponse(ApacheServerResponse* pResponse);
6369

Original file line numberDiff line numberDiff line change
@@ -1,7 +1,2 @@
1-
set(SAMPLE_NAME "FormServer")
2-
3-
set(LOCAL_SRCS "")
4-
aux_source_directory(src LOCAL_SRCS)
5-
6-
add_library( ${SAMPLE_NAME} ${LOCAL_SRCS} )
7-
target_link_libraries( ${SAMPLE_NAME} PocoNet PocoFoundation )
1+
add_library(FormServer src/FormServer.cpp)
2+
target_link_libraries(FormServer PUBLIC Poco::Net)
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,2 @@
1-
set(SAMPLE_NAME "TimeServer-apache")
2-
3-
set(LOCAL_SRCS "")
4-
aux_source_directory(src LOCAL_SRCS)
5-
6-
add_library( ${SAMPLE_NAME} ${LOCAL_SRCS} )
7-
target_link_libraries( ${SAMPLE_NAME} PocoNet PocoFoundation )
1+
add_library(TimeServer-apache src/TimeServer.cpp)
2+
target_link_libraries(TimeServer-apache PUBLIC Poco::Net)

ApacheConnector/src/ApacheConnector.cpp

+38-17
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@ int ApacheRequestRec::sendFile(const std::string& path, unsigned int fileSize, c
131131
}
132132

133133

134+
bool ApacheRequestRec::secure()
135+
{
136+
return DEFAULT_HTTPS_PORT == ap_default_port(_pRec) && ap_http_scheme(_pRec) == "https";
137+
}
138+
139+
134140
void ApacheRequestRec::copyHeaders(ApacheServerRequest& request)
135141
{
136142
const apr_array_header_t* arr = apr_table_elts(_pRec->headers_in);
@@ -149,7 +155,13 @@ void ApacheRequestRec::copyHeaders(ApacheServerRequest& request)
149155

150156
void ApacheConnector::log(const char* file, int line, int level, int status, const char *text)
151157
{
152-
ap_log_error(file, line, level, 0, NULL, "%s", text);
158+
// ap_log_error() has undergone significant changes in Apache 2.4.
159+
// Validate Apache version for using a proper ap_log_error() version.
160+
#if AP_SERVER_MAJORVERSION_NUMBER == 2 && AP_SERVER_MINORVERSION_NUMBER < 4
161+
ap_log_error(file, line, level, 0, NULL, "%s", text);
162+
#else
163+
ap_log_error(file, line, level, 0, 0, 0, text);
164+
#endif
153165
}
154166

155167

@@ -172,24 +184,33 @@ extern "C" int ApacheConnector_handler(request_rec *r)
172184
if ((rv = ap_setup_client_block(r, REQUEST_CHUNKED_DECHUNK)))
173185
return rv;
174186

187+
// The properties conn_rec->remote_ip and conn_rec->remote_addr have undergone significant changes in Apache 2.4.
188+
// Validate Apache version for using conn_rec->remote_ip and conn_rec->remote_addr proper versions.
189+
#if AP_SERVER_MAJORVERSION_NUMBER == 2 && AP_SERVER_MINORVERSION_NUMBER < 4
190+
const char* clientIp = r->connection->remote_ip;
191+
apr_port_t clientPort = r->connection->remote_addr->port;
192+
#else
193+
const char* clientIp = r->connection->client_ip;
194+
apr_port_t clientPort = r->connection->client_addr->port;
195+
#endif
175196
#ifndef POCO_ENABLE_CPP11
176-
std::auto_ptr<ApacheServerRequest> pRequest(new ApacheServerRequest(
177-
&rec,
178-
r->connection->local_ip,
179-
r->connection->local_addr->port,
180-
r->connection->remote_ip,
181-
r->connection->remote_addr->port));
182-
183-
std::auto_ptr<ApacheServerResponse> pResponse(new ApacheServerResponse(pRequest.get()));
197+
std::auto_ptr<ApacheServerRequest> pRequest(new ApacheServerRequest(
198+
&rec,
199+
r->connection->local_ip,
200+
r->connection->local_addr->port,
201+
clientIp,
202+
clientPort));
203+
204+
std::auto_ptr<ApacheServerResponse> pResponse(new ApacheServerResponse(pRequest.get()));
184205
#else
185-
std::unique_ptr<ApacheServerRequest> pRequest(new ApacheServerRequest(
186-
&rec,
187-
r->connection->local_ip,
188-
r->connection->local_addr->port,
189-
r->connection->remote_ip,
190-
r->connection->remote_addr->port));
191-
192-
std::unique_ptr<ApacheServerResponse> pResponse(new ApacheServerResponse(pRequest.get()));
206+
std::unique_ptr<ApacheServerRequest> pRequest(new ApacheServerRequest(
207+
&rec,
208+
r->connection->local_ip,
209+
r->connection->local_addr->port,
210+
clientIp,
211+
clientPort));
212+
213+
std::unique_ptr<ApacheServerResponse> pResponse(new ApacheServerResponse(pRequest.get()));
193214
#endif // POCO_ENABLE_CPP11
194215

195216
// add header information to request

ApacheConnector/src/ApacheServerRequest.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ ApacheServerRequest::~ApacheServerRequest()
3535
delete _pStream;
3636
}
3737

38-
38+
3939
const Poco::Net::HTTPServerParams& ApacheServerRequest::serverParams() const
4040
{
4141
throw Poco::NotImplementedException("No HTTPServerParams available in Apache modules.");
@@ -58,3 +58,9 @@ bool ApacheServerRequest::expectContinue() const
5858
{
5959
return false;
6060
}
61+
62+
63+
bool ApacheServerRequest::secure() const
64+
{
65+
return _pApacheRequest->secure();
66+
}

0 commit comments

Comments
 (0)