-
Notifications
You must be signed in to change notification settings - Fork 17
Build Copilot Windows
These instructions are for setting up your computer to build the Windows version of SolarPILOT's API (CoPILOT) from the C++ code repositories. The entire setup process should take between one and two hours. Once your computer is set up, it should take several minutes to build CoPILOT.
Note. If you are planning to build and use both SolarPILOT's GUI and API (CoPILOT), follow the SolarPILOT Windows build instructions, then skip to Step 6 on this page to build CoPILOT.
- Follow steps 1 and 3 in the SolarPILOT Windows build instructions
- Download and install Visual Studio Community 2019.
- Download and install CMake 3.16.
-
Clone CoPILOT code repositories.
-
Set environment variables.
-
Run CMake to generate SolarPILOT VS 2019 project files.
-
Build SolarPILOT.dll.
-
Test the build.
The repositories required to build SolarPILOT's API are SSC and SolTrace:
The latest code is in the develop
branch of each repository except for ssc, which uses the solarpilot-develop
branch. Make sure you check out the solarpilot-develop branch after cloning ssc. If you are contributing code, you should work from the develop
(or solarpilot-develop
) branch. To build a specific version of SolarPILOT, you can check out a tag for that version.
-
Create a parent folder to store the repositories, for example
...\solarpilot_dev
. -
Clone each repository into the parent folder.
-
Rename the 'ssc' folder to 'ssc-solarpilot'.
...\solarpilot_dev\ssc-solarpilot ...\solarpilot_dev\soltrace
SolarPILOT's build tools use Windows environment variables to determine where the files it needs are stored on your computer.
Note. This step is only required the first time you build SolarPILOT, or if you move or rename repository folders.
-
Close any open Command windows and Visual Studio if it is running.
-
Open the Windows System Properties window, and on the Advanced tab, click Environment Variables.
-
Under the user variables list, click New, and type values for the variable name and value for each item in the table below.
For example, if you put the SSC repository in
c:\solarpilot_dev\ssc-solarpilot
, you would set the environment variable's name to "SSCDIR" and its value to "c:\solarpilot_dev\ssc-solarpilot" (you do not need to type the quotes).SSCDIR ...\solarpilot_dev\ssc-solarpilot CORETRACEDIR ...\solarpilot_dev\soltrace\coretrace -
Close the System Properties window.
Note. This step is only required the first time you build SolarPILOT or if you have added or removed
.cpp
source files from theCMakeLists.txt
file for SSC or coretrace.
-
Use a text editor to create
CMakeLists.txt
in the SolarPILOT parent folder (...\solarpilot_dev\CMakeLists.txt
in our example) with the following contents:cmake_minimum_required(VERSION 3.12) Project(solarpilot_api) add_subdirectory(ssc-solarpilot) add_subdirectory(soltrace/coretrace)
Note that there can only be one file with the name'CMakelists.txt' in the build directory, so if you have used this directory for another CMake build, you will need to temporarily rename or move the other existing 'CMakelists.txt' file.
Note. If you are planning to build both SolarPILOT GUI and API, you can create
CMakeLists.txt
with the following contents:
cmake_minimum_required(VERSION 3.12)
# Uncomment the project to build
#Project(solarpilot_ui)
Project(solarpilot_api)
if(${CMAKE_PROJECT_NAME} STREQUAL "solarpilot_ui")
add_subdirectory(lk)
add_subdirectory(wex)
endif()
add_subdirectory(ssc-solarpilot)
add_subdirectory(soltrace/coretrace)
if(${CMAKE_PROJECT_NAME} STREQUAL "solarpilot_ui")
add_subdirectory(solarpilot)
endif()
-
Create a folder named
build-solarpilot
in the SolarPILOT parent folder (...\solarpilot_dev\build-solarpilot
). You should now have a directory structure for SolarPILOT that looks like this (for our example, this would be the contents of...\solarpilot_dev
):build-solarpilot soltrace ssc-solarpilot CMakeLists.txt
-
Open a command window, and go to the
build-solarpilot
folder you created above. -
Run the following CMake command:
cmake -G "Visual Studio 16 2019" -DCMAKE_CONFIGURATION_TYPES="Debug;Release" -DCMAKE_SYSTEM_VERSION=10.0 -DCOPILOT_API=1 ..
When CMake finishes, you should see ...\build-solarpilot\solarpilot_api.sln
file, with supporting files and a folder for each SolarPILOT repository in the build-solarpilot folder.
If you get build errors about missing files, check the environment variables to makes sure they are correctly named and point to the correct folders.
If you are running CMake to generate a new solution file after creating or removing .cpp files from the SSC or coretrace repositories, go to the ...\solarpilot_dev
folder, and use the following commands from a command window or batch (.bat) file to clean up before running CMake:
rmdir /Q/S build-solarpilot
mkdir build-solarpilot
cd build-solarpilot
cmake -G "Visual Studio 16 2019" -DCMAKE_CONFIGURATION_TYPES="Debug;Release" -DCMAKE_SYSTEM_VERSION=10.0 -DCOPILOT_API=1 ..
- (Optional, but recommended): Add an .editorconfig file to the ...\solarpilot_dev folder to ensure your code is formatted consistently with project standards.
-
Start VS 2019 and open the
...\build-solarpilot\solarpilot_api.sln
solution file. -
On the Build menu, click Batch Build and then Select All.
-
Click Build.
Notes
As a post-build step, SolarPILOT's Dynamic-link library (.dll) will be copied here:
...solarpilot_dev', unless you have cloned the SolarPILOT's repository within the
...solarpilot_dev' directory, then the .dll will be copied here:...solarpilot_dev\solarpilot\deploy\api
.The files for coretrace and SSC are in the
...solarpilot_dev\build-solarpilot
folders for each repository, for examplesolarpilot_dev\build-solarpilot\ssc-solarpilot\Release
.SSC and coretrace each have their own repository in GitHub.com, so changes should be committed to each repository.
-
Download the SolarPILOT's repository directory:
...\solarpilot\deploy\api
. -
Copy the
solarpilot.dll
into theapi
directory. -
Run
test_script.py
.