Skip to content
This repository has been archived by the owner on Sep 27, 2019. It is now read-only.

Commit

Permalink
Build on Windows (MSVC)
Browse files Browse the repository at this point in the history
Signed-off-by: Uilian Ries <[email protected]>
  • Loading branch information
uilianries committed Mar 17, 2018
1 parent a5077c9 commit 58f9a50
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def build(self):
cmake = CMake(self)
cmake.definitions["PCRE_BUILD_TESTS"] = False
if self.settings.os == "Windows" and self.settings.compiler == "Visual Studio":
cmake.definitions["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = self.options.shared
cmake.definitions["PCRE_STATIC_RUNTIME"] = not self.options.shared and "MT" in self.settings.compiler.runtime
cmake.configure(build_folder=self.build_subfolder)
cmake.build()
cmake.install()
Expand Down
3 changes: 3 additions & 0 deletions test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ file(GLOB SOURCE_FILES *.c)

add_executable(${PROJECT_NAME} ${SOURCE_FILES})
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
if (PCRE_STATIC)
target_compile_definitions(${PROJECT_NAME} PRIVATE PCRE_STATIC=1)
endif (PCRE_STATIC)
6 changes: 5 additions & 1 deletion test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@ class TestPackageConan(ConanFile):

def build(self):
cmake = CMake(self)
if self.settings.os == "Windows" and \
self.settings.compiler == "Visual Studio" and \
not self.options['pcre'].shared:
cmake.definitions['PCRE_STATIC'] = True
cmake.configure()
cmake.build()

def test(self):
with tools.environment_append(RunEnvironment(self).vars):
bin_path = os.path.join("bin", "test_package")
arguments = "\\\\d+ 2018"
arguments = "%sw+ Bincrafters" % "\\" if self.settings.os == "Windows" else "\\\\"
if self.settings.os == "Windows":
self.run("%s %s" % (bin_path, arguments))
elif self.settings.os == "Macos":
Expand Down
2 changes: 1 addition & 1 deletion test_package/test_package.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ unwanted results. So in this environment, uncomment the following line. */

#include <stdio.h>
#include <string.h>
#include <pcre.h>
#include "pcre.h"

#define OVECCOUNT 30 /* should be a multiple of 3 */

Expand Down

0 comments on commit 58f9a50

Please sign in to comment.